Scanner Class

Parsing and reading input

Scanner Class

Scanner is used to parse primitive types and strings.

Code Examples

Reading user input

java
1
2Scanner sc = new Scanner(System.in);
3int x = sc.nextInt();
4          

Use Cases

  • Console input

Common Mistakes to Avoid

  • Performance issues with large input