Web hosting domains - 60 Introduction to Java Applications Chapter 2 Line
60 Introduction to Java Applications Chapter 2 Line 5 is a blank line, inserted for program readability. Line 6, // main method begins execution of Java application is a single-line comment indicating the purpose of lines 6 11 of the program. Line 7, public static void main( String args[] ) is a part of every Java application. Java applications begin executing at main. The parentheses after main indicate that main is a program building block called a method. Java class definitions normally contain one or more methods. For a Java application class, exactly one of those methods must be called main and must be defined as shown on line 7; otherwise, the java interpreter will not execute the application. Methods are able to perform tasks and return information when they complete their tasks. The void keyword indicates that this method will perform a task (displaying a line of text, in this program), but will not return any information when it completes its task. Later, we will see that many methods return information when they complete their task. Methods are explained in detail in Chapter 6. For now, simply mimic main s first line in your Java applications. The left brace, {, on line 8 begins the body of the method definition. A corresponding right brace, }, must end the method definition s body (line 11 of the program). Notice that the line in the body of the method is indented between the braces. Good Programming Practice 2.9 Indent the entire body of each method definition one level of indentation between the left brace, {, and the right brace, }, that define the body of the method. This format makes the structure of the method stand out and helps make the method definition easier to read. Line 9, System.out.println( “Welcome to Java Programming!” ); instructs the computer to perform an action, namely to print the string of characters contained between the double quotation marks. A string is sometimes called a character string, a message or a string literal. We refer to characters between double quotation marks generically as strings. White-space characters in strings are not ignored by the compiler. System.out is known as the standard output object. System.out allows Java applications to display strings and other types of information in the command window from which the Java application executes. In Microsoft Windows 95/98/ME, the command window is the MS-DOS prompt. In Microsoft Windows NT/2000, the command window is the Command Prompt (cmd.exe). In UNIX, the command window is normally called a command window, a command tool, a shell tool or a shell. On computers running an operating system that does not have a command window (such as a Macintosh), the java interpreter normally displays a window containing the information the program displays. Method System.out.printlndisplays (or prints) a line of text in the command window. When System.out.println completes its task, it automatically positions the output cursor (the location where the next character will be displayed) to the beginning of the next line in the command window. (This move of the cursor is similar to you pressing the Enter key when typing in a text editor the cursor appears at the beginning of the next line in your file.) Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for cheap webhost to host and run your apache application check Vision jboss web hosting services