import javax.swing.JOptionPane; /** * A class to illustrate the use of public static void main.
* The user can either enter his/her name on the command line or * interactively */ public class Salutations { public static void main(String[] args) { String name; if (args.length==0) // interactive input name = JOptionPane.showInputDialog(null,"What is your name?"); else // the name was given on the command line name = args[0]; // Say hello System.out.println("Hi, "+name+". How are you today?"); // Terminate the application // (any program using graphics must terminate this way) System.exit(0); } }