write down the syntax to accept an integer value through scanner class
Answers
Answered by
3
Answer:
Hope it helped you please mark as brainlist
Explanation:
We are using nextInt() method of Scanner class to read the integer.
Answered by
3
Explanation:
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
/* This reads the input provided by user
* using keyboard
*/
Scanner scan = new Scanner(System.in);
System.out.print("Enter any number: ");
// This method reads the number provided using keyboard
int num = scan.nextInt();
// Closing Scanner after the use
scan.close();
// Displaying the number
System.out.println("The number entered by user: "+num);
}
Similar questions