JAVAWarningApril 16, 2026

Syntax Error

Cannot find symbol: method 'get' on class 'Scanner'

What This Error Means

This error occurs when the Java compiler cannot find a method or variable that is being used in the code. In this case, it's because the 'get' method is being used on an instance of the Scanner class, but the 'get' method does not exist in the Scanner class. Instead, Scanner has a method called 'next' which is used to get the next token from the input.

Why It Happens

This error typically happens when a programmer is using a method or variable that does not exist in the class or object they are working with. This can be due to a typo in the method or variable name, or because the programmer is not familiar with the methods and variables available in a particular class. In this case, the programmer likely meant to use the 'next' method instead of 'get'.

How to Fix It

  1. 1To fix this error, replace 'get' with 'next'. For example, if you have a line of code that looks like this: 'Scanner scanner = new Scanner(System.in); String input = scanner.get();', you should change it to: 'Scanner scanner = new Scanner(System.in); String input = scanner.next();'.

Example Code Solution

❌ Before (problematic code)
Java
Scanner scanner = new Scanner(System.in);
String input = scanner.get();
✅ After (fixed code)
Java
Scanner scanner = new Scanner(System.in);
String input = scanner.next();

Fix for Cannot find symbol: method 'get' on class 'Scanner'

Related JAVA Errors

Related JAVA Blog Articles

Have a different error? Get an instant explanation.

Explain Another Error