I am a
Java newbie and please help me improve this program.
I want to restrict the user to enter only a
word less than 6 letters. If he enters more than 5 I have to make him try again. I tried to use while loop in various ways but I am getting errors. Could someone help me?
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class EchoUsingIOPackage
{
public static void main (
String args[]) throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
//I need to start a loop here so that I can rerun this part if the user enters more than 5 characters.
System.out.println("Type some word (less than 6 characters) here and I will repeat
it Three times! ");
String input = br.readLine();
//End loop here
System.out.println(input + " " + input + " " + input);
}
}
-Kiran