What class can I use for reading an integer variable in Java?
You can use java.util.Scanner (API):
java.util.Scanner
import java.util.Scanner; //... Scanner in = new Scanner(System.in); int num = in.nextInt();
It can also tokenize input with regular expression, etc. The API has examples and there are many others in this site (e.g. How do I keep a scanner from throwing exceptions when the wrong type is entered?).
1.4m articles
1.4m replys
5 comments
57.0k users