- Feb 16, 2003
- 26,108
- 5
- 81
I'm writing a program for CS that has to check an input string to see if it basically has any two letters that are the same. Well, everything is basically done and now I'm going back and doing the other small stuff that could be major. Anyway, this method needs to check for errors, and my first is checking for a space in the input because it is only supposed to be for one word. Here is my method:
public static String checkInput(String errCheck) throws IOException
{
if (errCheck.indexOf(" ") != - 1)
{
System.out.print("Please enter a single word: ");
errCheck = dataIn.readLine();
while (errCheck.indexOf(" ") != - 1) checkInput(errCheck);
}
return errCheck;
}