#1. How to Take Integer Input From User In Java Using Scanner Class??

Very simple basic java program through which we can get inputs from the user in the form of integer and then at the output, we will get those inputs and also sum of those inputs as well using Scanner Class.

import java.util.Scanner;

public class UserInput{
	
public static void main (String[] args){
		
Scanner sc = new Scanner(System.in);   // to get inputs from users
System.out.println("Enter 1st Number");
int number1 = sc.nextInt();
		
System.out.println("Enter 2nd Number");
int number2 = sc.nextInt();
		
System.out.println("Your Entered Number is");
		
System.out.println(number1+ " and " +number2);
		
int sum = number1 + number2;
System.out.println("The sum is: " +sum);	
		
	}	
}

When you run the above program, the Output looks like:

Watch the video below for complete explanation of the above program step by step:

MORE CORE JAVA PROGRAMS