68 Introduction to (Web site design) Java Applications Chapter 2 Executing

68 Introduction to Java Applications Chapter 2 Executing the statement at lines 12 13 displays the dialog box in Fig. 2.8. The title bar of the dialog contains the string Message, to indicate that the dialog is presenting a message to the user. The dialog box automatically includes an OK button that allows the user to dismiss (hide) the dialog by pressing the button. This is accomplished by positioning the mouse cursor (also called the mouse pointer) over the OK button and clicking the left mouse button. Remember that all statements in Java end with a semicolon (;). Therefore, lines 12 13 represent one statement. Java allows large statements to be split over many lines. However, you cannot split a statement in the middle of an identifier or in the middle of a string. Common Programming Error 2.8 Splitting a statement in the middle of an identifier or a string is a syntax error. Line 15, System.exit( 0 ); // terminate application uses staticmethod exitof class Systemto terminate the application. In any application that displays a graphical user interface, this line is required in order to terminate the application. Notice once again the syntax used to call the method the class name (System), a dot (.) and the method name (exit). Remember that identifiers starting with capital letters normally represent class names. So, you can assume that System is a class. Class System is part of the package java.lang. Notice that class System is not imported with an import statement at the beginning of the program. By default, package java.langis imported in every Java program. Package java.langis the only package in the Java API for which you are not required to provide an importstatement. The argument 0to method exitindicates that the application has terminated successfully. (A nonzero value normally indicates that an error has occurred.) This value is passed to the command window that executed the program. The argument is useful if the program is executed from a batch file (on Windows 95/98/ME/NT/2000 systems) or a shell script (on UNIX/Linux systems). Batch files and shell scripts often execute several programs in sequence. When the first program ends, the next program begins execution automatically. It is possible to use the argument to method exitin a batch file or shell script to determine whether other programs should execute. For more information on batch files or shell scripts, see your operating system s documentation. Title bar The OK button allows the user to dismiss the dialog box. The dialog box is automatically sized to accommodate the string. Mouse cursor Fig. 2.8 Message dialog box. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services

Leave a Reply