Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views

ProgLesson4 Java User Input

The document discusses how to get user input in Java using the Scanner class. The Scanner class reads input from the user via System.in and has methods like nextLine() to read strings from the user. An example program is provided that gets personal information from the user using Java input.

Uploaded by

Jerlon Zuñiga
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

ProgLesson4 Java User Input

The document discusses how to get user input in Java using the Scanner class. The Scanner class reads input from the user via System.in and has methods like nextLine() to read strings from the user. An example program is provided that gets personal information from the user using Java input.

Uploaded by

Jerlon Zuñiga
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Programming

Java User Input


Java User Input
The Scanner class is used to get user input, and it is found in the java.util
package.

To get the instance of Java Scanner which reads input from the user, we
need to pass the input stream (System.in) in the constructor of Scanner
class.

Scanner in = new Scanner (System.in);

To use the Scanner class, create an object of the class and use any of
the available methods found in the Scanner class documentation. In our
example, we will use the nextLine() method, which is used to read
Strings:
Output:
Input Types
In the previous example, we used nextLine() method which is used to read Strings. To read other types, look at the table below.
Output:
Output:
Activity
Design a program that will display your 20 personal information using Java
Input. Show your code and output.
THANK YOU
Java User Input

You might also like