Computer Applications

Write down the use of nextInt() method.

Input in Java

12 Likes

Answer

The method nextInt( ) is used to input an integer number and store it in an integer type variable.

Syntax

int <variable> = <scannerObject>.nextInt( );

For example,

Scanner in = new Scanner(System.in);   
int p = in.nextInt();

This signifies that the variable p will store an integer number.

Answered By

8 Likes


Related Questions