Email web hosting - 54 Part I: Getting Started Figure 3-3: The

54 Part I: Getting Started Figure 3-3: The main method. The main method’s headerThe main method (also known as the main method’s declaration) public static void main(String args[]) { System.out.println(”You’ll love Java!”); } class Displayer { } The main method’s body The word main plays a special role in Java. In particular, you never write code that explicitly calls a mainmethod into action. The word main is the name of the method that is called into action automatically when the program begins running. So look back at Figure 3-1. From within JCreator you choose Build.Execute Project to run the Displayerprogram. When the Displayerprogram runs, the computer automatically finds the program s mainmethod and executes any instructions inside the method s body. In the Displayerprogram, the mainmethod s body has only one instruction. That instruction tells the computer to print You ll love Java!on the screen. So in Figure 3-1, You ll love Java!appears in JCreator s General Output pane. None of the instructions in a method is executed until the method is called into action. But, if you give a method the name main, that method is called into action automatically. Almost every computer programming language has something akin to Java s methods. If you ve worked with other languages, you may remember things like subprograms, procedures, functions, subroutines, subprocedures, or PERFORMstatements. Whatever you call it in your favorite programming language, a method is a bunch of instructions collected and given a new name. How you finally tell the computer to do something Buried deep in the heart of Listing 3-1 is the single line that actually issues a direct instruction to the computer. The line, which is highlighted in Figure 3-4,
Please check java servlet web hosting services, here you will find professional-grade java servlet web hosting with the best prices.

Leave a Reply