Hello friends I encountered a problem i,e
import java.io.*;
public class execute {
public static void main(String args[])throws Exception{
char cname;
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter a letter");
cname= (char)br.read();
if(cname==' '){
System.out.println("u entered a space");
}
else {
System.out.println("u entered a character");
}
}
}
In the above program, help in writing a loop such that
until and unless a character is entered(as input from keyboard) ,it should keep asking me to "Enter a character"
Software/Hardware used:
eclipse
ASKED:
March 18, 2010 4:04 AM
UPDATED:
November 5, 2011 4:27 PM
lets keep the code in the try block if the input is any space u keep it in that and catch in catch block or in finally block u keep the loop.It might solve ur problem