I'm trying to evaluate user input, but the while statement seems to go into an infinite loop without asking for input.
import javax.swing.JOptionPane;
public class StringMethodsTwo {
public static void main(String[] args)
{
String sFullName = " ";
String prompt = "Please enter your full name:";
while(sFullName.startsWith(" "));
{
sFullName = getInput(prompt);
if(sFullName.length() < 2)
{
prompt = "Please enter your full name, \"<first> <middle> <last>\":";
}
}
}
public static String getInput(String prompt)
{
return JOptionPane.showInputDialog(null, prompt);
}
}
You are doing the loop
while(sFullName.startsWith(" ")); // while(true);
{
Delete the ";"