System.in

webmasterbeta

New Member
I'm trying to read characters one by one from the keyboard & print them usingthis program. But instead of printing thecharacter I enter it always displays the last character of themessage "Enter a character" ? How do I solve this problem ?thanxSeemaclass testio{public static void main(String args[]) throws Exception{BufferedReader br=new BufferedReader(newInputStreamReader(System.in));char c='x';while(c!='0'){System.out.print("Enter character");c=(char)br.read();System.out.print(c);}}}
 
Back
Top