Read The Input Number Entered By User | Java Programs

Output:

*** Take Input From User ***

Enter any number: 1868
You entered: 1868

Click Here For Java Online Compiler

Solution:

import java.util.Scanner;

class Input {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        System.out.println("*** Take Input From User ***" + "\n");
        System.out.print("Enter any number: ");

        // This method reads the number provided using keyboard
        int num = sc.nextInt();

        System.out.println("You entered: " + num);
    }
}
Share This :

Related Post



sentiment_satisfied Emoticon