• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can I do this?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic