Free web hosting music - Chapter 2 Introduction to Java Applications 61 The

Chapter 2 Introduction to Java Applications 61 The entire line, including System.out.println, its argument in the parentheses (the string) and the semicolon (;), is a statement. Every statement must end with a semicolon (also known as the statement terminator). When the statement on line 9 of our program executes, it displays the message Welcome to Java Programming! in the command window. Common Programming Error 2.6 Omitting the semicolon at the end of a statement is a syntax error. A syntax error occurs when the compiler cannot recognize a statement. The compiler normally issues an error message to help the programmer identify and fix the incorrect statement. Syntax errors are violations of the language rules. Syntax errors are also called compile errors, compile-time errors or compilation errors, because the compiler detects them during the compilation phase. You will be unable to execute your program until you correct all of the syntax errors in it. Testing and Debugging Tip 2.1 When the compiler reports a syntax error, the error may not be on the line number indicated by the error message. First, check the line for which the error was reported. If that line does not contain syntax errors, check the preceding several lines in the program. Some programmers find it difficult when reading and/or writing a program to match the left and right braces ({ and }) that delimit the body of a class definition or a method definition. For this reason, some programmers prefer to include a single-line comment after a closing right brace (}) that ends a method definition and after a closing right brace that ends a class definition. For example, line 11, } // end method main specifies the closing right brace (}) of method main, and line 13, } // end class Welcome1 specifies the closing right brace (}) of class Welcome1. Each comment indicates the method or class that the right brace terminates. We use such comments through Chapter 6 to help beginning programmers determine where each program component terminates. After Chapter 6, we use such comments when pairs of braces contain many statements, which makes the closing braces difficult to identify. Good Programming Practice 2.10 Some programmers prefer to follow the closing right brace (}) of a method body or class definition with a single-line comment indicating the method or class definition to which the brace belongs. This comment improves program readability. 2.2.1 Compiling and Executing your First Java Application We are now ready to compile and execute our program. To compile the program, we open a command window, change to the directory where the program is stored and type javac Welcome1.java If the program contains no syntax errors, the preceding command creates a new file called Welcome1.class containing the Java bytecodes that represent our application. These bytecodes will be interpreted by the java interpreter when we tell it to execute the program, as shown in the Microsoft Windows 2000 Command Prompt of Fig. 2.2. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check Vision professional web hosting services

Leave a Reply