Simple question involving Strings and JOptionPane
As the forum suggests, I'm new to Java.
Essentially what I'm trying to do is create an if statement that will restart the class if a value entered into a JOptionPane.showInputDialog box isn't a valid entry.
Code:
public void input()
{
String s = JOptionPane.showInputDialog("Input a value");
[B]if (s ?)[/B]
{
JOptionPane.showMessageDialog(null, "Error: You must enter a valid value.",
"Error", JOptionPane.ERROR_MESSAGE);
input();
}
In this case a valid input would be a number. Ex: 20
An invalid input would be anything involving characters. Ex: Twenty
Also an invalid input would be leaving the input dialog box empty
So how should I structure the if argument to do this?