62 Introduction to Java Applications (Top ten web hosting) Chapter 2 Fig.
62 Introduction to Java Applications Chapter 2 Fig. 2.2 Executing Welcome1in a Microsoft Windows 2000 Command Prompt. In the command prompt of Figure 2.2, we typed java Welcome1 to launch the javainterpreter and indicate that it should load the .class file for class Welcome1. Note that the .class file-name extension is omitted from the preceding command; otherwise the interpreter will not execute the program. The interpreter automatically calls method main. Next, the statement on line 7 of maindisplays Welcome to JavaProgramming! Testing and Debugging Tip 2.2 The Java compiler generates syntax error messages when the syntax of a program is incorrect. When you are learning how to program, sometimes it is helpful to break a working program so you can see the error messages produced by the compiler. Then, when you encounter that error message again, you will have an idea of the error s cause. Try removing a semicolon or curly brace from the program of Fig. 2.1, then recompile the program to see the error messages generated by the omission. 2.3 Modifying Our First Java Program This section continues our introduction to Java programming with two examples that modify the example in Fig. 2.1 to print text on one line by using multiple statements and to print text on several lines by using a single statement. 2.3.1 Displaying a Single Line of Text with Multiple Statements Welcome to Java Programming! can be displayed using several methods. Class Welcome2, shown in Fig. 2.3, uses two statements to produce the same output as that shown in Fig. 2.1. Most of the program is identical to that of Fig. 2.1, so we discuss only the changes here. Line 2, // Printing a line of text with multiple statements. is a single-line comment stating the purpose of this program. Line 4 begins the definition of class Welcome2. Lines 9 10 of method main, System.out.print( “Welcome to ” ); System.out.println( “Java Programming!” ); 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