Accepting input from user in Java

Hi

Which of the following is the formal/best method for accepting input from user and what library we need to import:

Scanner user_input = new Scanner( System.in );

InputStreamReader isr = new inputStreamReader(System.in)

Thanks
JRawabiAsked:
Who is Participating?
 
krakatoaCommented:
java.util.Scanner. ;)
0
 
JRawabiAuthor Commented:
forgot this:


Also this

System.out.print("Enter the input");
 usrInpt = scan.next();
0
 
mrcoffee365Commented:
We use InputStreamReader usually, but krakatoa is right, Scanner works, too.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.