First, I am running on linux and when i use the java command to run a program (i.e. java foo), it just sits after it finishes. how can I get it to fully close(specifically, the program I am posting at the end of this post)
Second, is there an equivalent to the return 0 in C++. i.e. input validation fails and you want to exit? I can't figure out how to do that.
here's the program I've written:
import javax.swing.*;
class Ch2Sample1
{
public static void main(String[] args)
{
String name;
while(true)
{
name = JOptionPane.showInputDialog(null, "What is your name?");
if(name.length()!=0)
break;
else
{
JOptionPane.showMessageDialog(null, "Oops! You didn't enter anything.\nPlease try again.");
}
}
JOptionPane.showMessageDialog(null, "Your name is " + name);
}
}