wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Can I do this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can I do this?" Watch "Can I do this?" New topic
Author

Can I do this?

John Chong
Greenhorn

Joined: Jan 18, 2001
Posts: 16
public class TestIO{
private static int a;
public static void main(String[] args){
System.out.println("Whats your name?");
System.in.readln(String n);
System.out.println("Hello "+n);
}
}
Shripad Bokil
Greenhorn

Joined: Jan 30, 2001
Posts: 13
Hi John,
The code you have written will not work....instead modify your code like this...I have tested it & it works perfectly.
import java.io.*;
public class TestIO{
private static int a;
public static void main(String[] args){
try{
BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Whats your name?");
String n=reader.readLine();
System.out.println("Hello "+n);
}catch(IOException e){
System.out.println("\n Error in reading " + e);
}
}
}
 
wood burning stoves
 
subject: Can I do this?