Java Notes Naveen
Java Notes Naveen
This line begins the main( ) method. As the comment preceding it suggests, this is the line at
which the program will begin executing. All Java applications begin execution by calling
main( ).
The public keyword is an access specifier, which allows the programmer to control the visibility
of class members. When a class member is preceded by public, then that member may be
accessed by code outside the class in which it is declared.
One other point: main( ) is simply a starting place for your program. A complex program will
have dozens of classes, only one of which will need to have a main( ) method to get things
started.
Static methods
Static methods use no instance variables of any object of the class they are defined in. If you
define a method to be static, you will be given a rude message by the compiler if you try to
access any instance variables. You can access static variables, but except for constants, this is
unusual. Static methods typically take all the data from parameters and compute something from
those parameters, with no reference to variables.