Java Reference
In-Depth Information
Summary
Methods must appear within a class in Java. A method's signature
denotes the name of the method, its access specifier, its return value,
any arguments that need to pass into the method, and any checked
exceptions that the method may throw.
■■
Arguments are passed to methods in Java using call-by-value, meaning
that a copy of the argument is passed to the method.
■■
A method can be overloaded, allowing a class to have more than one
method with the same name as long as the parameter lists are different.
■■
Every class has at least one constructor, a unique type of method that is
invoked when the class is instantiated. The name of a constructor must
match the name of the class, and no return value is declared.
■■
If a class does not declare a constructor, the compiler adds the default
constructor to the class. The default constructor has no parameters and
does not do anything.
■■
A constructor can invoke another constructor in the same class using
the this() syntax, which must be the first statement in the constructor.
■■
Search WWH ::




Custom Search