[Program] How to read three different values using Scanner in Java

Java Scanner Program to read three inputs
Java Scanner Program to read three inputs
Program: How to read three different values using Scanner in Java?

import java.util.Scanner;

 * Program to read three integers
 * as input using Scanner Class
 * Code2care.org Java Programs
 * Update: 19 March 2022
public class ScannerReadExample {

    public static void main(String... args) {

        Scanner scannerObject = new Scanner(System.in);

        System.out.print("Enter value of first Integer: ");
        int firstInteger=scannerObject.nextInt();

        System.out.print("Enter value of second Integer: ");
        int secondInteger=scannerObject.nextInt();

        System.out.print("Enter value of third Integer: ");
        int thirdInteger=scannerObject.nextInt();

        System.out.println("---------- Output -----------");
        System.out.println("Entered 1st Integer Value: " + firstInteger);
        System.out.println("Entered 2nd Integer Value: " + secondInteger);
        System.out.println("Entered 3rd Integer Value: " + thirdInteger);


% javac ScannerReadExample.java

% java ScannerReadExample
Enter value of first Integer: 5
Enter value of second Integer: 10
Enter value of third Integer: 15

---------- Output -----------
Entered 1st Integer Value: 5
Entered 2nd Integer Value: 10
Entered 3rd Integer Value: 15

Try Out Code2care Dev Tools:


#Android #Java #Linux #Microsoft #Google #Python #MacOS #Notepad++ #Microsoft Teams #CSS #PHP #SharePoint #Html #Linux #C-Program #Bootstrap #jQuery #Sublime #Android-Studio #Facebook #Eclipse #WhatsApp #News #MySQL #Json #HowTos #JavaScript #FTP #S3


Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Tutorials, Trouble-Shooting steps, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.
🎉 We are celebrating the 10th years of Code2care! Thank you for all your support! We hope we made a difference.
We strong support Gender Equality & Diversity.

We stand in solidarity with Ukraine - Make a donation to UNHCR - https://donate.unhcr.org/in/en-in/ukraine-emergency