
Code:
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);
}
}
Output:
% 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
- Create a Zip file using Java Code programmatically
- Eclipse : A java Runtime Environment (JRE) or Java Development kit (JDK) must be available
- How to Sort a LinkedList in Java
- Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver
- How to declare and initialize Array in Java Programming
- [Fix] java: integer number too large compilation error
- Java JDBC Connection with MySQL Driver in VS Code + Troubleshooting
- Reading .xls and .xlsx Excel file using Apache POI Java Library
- IntelliJ: Error: Could not find or load main class, java.lang.ClassNotFoundException
- How to get Client IP address using Java Code Example
- Truncate table using Java JDBC Example
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- How to get file path in Idea IntelliJ IDE
- Java Generics explained with simple definition and examples
- Java SE 8 Update 301 available with various bug fixes and security improvements
- Java: Collect Stream as ArrayList or LinkedList
- Java JDBC Connection with PostgreSQL Driver Example
- How to check if Java main thread is alive
- How to fix Java nio NoSuchFileException wile reading a file
- Java 8+ get Day of the Week Examples with LocalDateTime, DateTime, ZonalDateTime and Instant classes
- Ways to Convert Integer or int to Long in Java
- [Java] How to throws Exception using Functional Interface and Lambda code
- [Fix] Spring Boot: mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
- Java: The value of the local variable string is not used
- Java JDBC: Insert Java 8 LocalDate and Time using PreparedStatement
- JSON Tutorial: List of Lessons - Json-Tutorial
- SQLite Error: unknown command or invalid arguments: open. Enter .help for help - Android
- How to create a Java Project as a Git Repository with IntelliJ - Java
- Simple Crossword Puzzle example using Pure HTML, CSS and JavaScript - Html
- Office.com downloading zero byte file name prelanding on Safari browser - Windows
- How to show or hide columns in SharePoint Online List Library from - SharePoint
- Step-by-Step: How to install Flutter in Android Studio - Android-Studio
- Fix Python WARNING: You are using pip version 19 however version 21 is available - PIP