0
I can't understand the user input in java can any one help me please
3 Answers
0
You can use the Scanner class to get user input
Scanner scan = new Scanner(System.in);
Wanna input a int? Use this
int num = scan.nextInt();
Now print it out
System.out.println("My number is "+num);
Dont forget to import java.util package so you can use the Scanner class, add this line to the top:
Import java.util.Scanner;
0
Thanks a lot for clarification at first i confused that scanner is a object but now i understand that it is a class and we need to create a object to it
0
You are welcome, glad i could help đ