This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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
posted
0
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); } } }