Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

user input

 
sagarika chinya
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am new to java and i wanted to know if there is a function like scanf which can accept user input?
thanks
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sagarika,
Welcome to Javaranch, a friendly place for Java greenhorns
In Java, you can retrieve characters typed on the keyboard by invoked the read() method on the System.in input stream.
For instance, the following program allows you to read three integer primitives from the keyboard:
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code samples at sun for reading and writing data
[ October 18, 2002: Message edited by: William Barnes ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic