Download Greet3.java source file
/* A simple program to display a friendly greeting. This stand-alone
* Java program demonstrates keyboard input using a simple GUI method.
* The use of a GUI input method in an otherwise non-gui program is okay
* in the classroom but probably not otherwise.
*
* Written by Wayne Pollock, Tampa, FL USA, 2002. Updated 2005 for Java5.
*/
import javax.swing.JOptionPane;
class Greet3
{
public static void main ( String [] args )
{
String name = JOptionPane.showInputDialog( "Please enter your name: " );
if ( name != null )
System.out.println( "Hello " + name + "!" );
} // End of main
} // End of class Greet3