Accepting input from user in Java

Posted on 2012-09-21
Last Modified: 2012-10-16

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( );

InputStreamReader isr = new inputStreamReader(

Question by:JRawabi

    Author Comment

    forgot this:

    Also this

    System.out.print("Enter the input");
     usrInpt =;
    LVL 16

    Accepted Solution

    java.util.Scanner. ;)
    LVL 26

    Expert Comment

    We use InputStreamReader usually, but krakatoa is right, Scanner works, too.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now