3-12 VariableScope

posted Jan 29, 2014, 6:12 AM by Dlovan ismail   [ updated Jan 29, 2014, 6:12 AM by Karwan Jacksi ]
/*
This program demonstrates how variables may be declared
in various locations throughout a program.
*/
package variablescope;
import javax.swing.JOptionPane; // Needed for JOptionPane

public class VariableScope 
{
    public static void main(String[] args)
    {     
            // Get the user's first name.
            String firstName;
            firstName = JOptionPane.showInputDialog("Enter your " +"first name.");

            // Get the user's last name.
            String lastName;
            lastName = JOptionPane.showInputDialog("Enter your "+"last name.");
             JOptionPane.showMessageDialog(null,"Hello, " + firstName +"  "+ lastName);

             System.exit(0);
    }   
}

ċ
VariableScope.java
(1k)
Karwan Jacksi,
Jan 29, 2014, 6:12 AM
Comments