3-12 VariableScope
Post date: Jan 29, 2014 2:12:14 PM
/*
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);
}
}