Chapter 2 Introduction to Java Applications 75 Message (Http web server)
Chapter 2 Introduction to Java Applications 75 Message dialog type Icon Description JOptionPane.ERROR_MESSAGE Displays a dialog that indicates an error to the user. JOptionPane.INFORMATION_MESSAGE Displays a dialog with an informational message to the user. The user can sim ply dismiss the dialog. JOptionPane.WARNING_MESSAGE Displays a dialog that warns the user of a potential problem. JOptionPane.QUESTION_MESSAGE Displays a dialog that poses a question to the user. This dialog normally requires a response, such as clicking on a Yes or a No button. JOptionPane.PLAIN_MESSAGE no icon Displays a dialog that simply contains a message, with no icon. Fig. 2.12 JOptionPaneconstants for message dialogs. 2.6 Memory Concepts Variable names such as number1, number2and sumactually correspond to locations in the computer’s memory. Every variable has a name, a type, a size and a value. In the addition program of Fig. 2.9, when the statement number1 = Integer.parseInt( firstNumber ); executes, the string previously typed by the user in the input dialog and stored in first- Number is converted to an int and placed into a memory location to which the name number1has been assigned by the compiler. Suppose that the user enters the string 45as the value for firstNumber. The program converts firstNumber to an int, and the computer places that integer value, 45, into location number1, as shown in Fig. 2.13. Whenever a value is placed in a memory location, the value replaces the previous value in that location. The previous value is destroyed (i.e., lost). When the statement number2 = Integer.parseInt( secondNumber ); executes, suppose that the user enters the string 72as the value for secondNumber. The program converts secondNumberto an int, and the computer places that integer value, 72, into location number2. The memory appears as shown in Fig. 2.14. number1 45 Fig. 2.1313 Memory location showing the name and value of variable number1. Fig. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/2/01