Wednesday, November 21, 2012

how to read the input in java

how to read the input in java

import java.io.*;
class wrd
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String input()
{
String txt=null;
System.out.print("Enter a word:");
try{
txt=br.readLine();
}
catch(IOException e){
System.out.println("Error at "+e);
}
return txt;
}
public static void main(String arg[])
{
wrd obj=new wrd();
System.out.println("Entered word is: "+obj.input());

}
}

0 comments:

Post a Comment