
7.4 Writing Constructors 377
In the method body, a method can declare variables, call other methods,
and use any of the program structures we’ve discussed: if/else statements,
while loops, for loops, switch statements, and do/while loops.
All objects of a class share one copy of the class methods.
We have actually written methods already. For example, we’ve written the
method main. Its definition looks like this:
public static void main( String [ ] args )
{
// application code
}
We know that the static keyword means that the Java Virtual Machine can
call main to start the application running without first instantiating an
object. The return type is void ...