Error:
cannot find symbol
symbol : class <class name>
Explanation:
You are using a class name that the compiler doesn't recognize.
Checklist:
- Have you imported the class named in the message?
- Is the class name spelled correctly? Check for typos, including capitalization. Remember that classes in the Java class library begin with a capital letter.
Example:
With the following statements in a source file named Input.java:
1 /* Input class */
2
3 public class Input
4 {
5 public static void main( String [] args )
6 {
7 Scanner scan = new Scanner( System.in );
// more code here
the Java compiler would generate the following errors:
Input.java:7: cannot find symbol
symbol : class Scanner
Scanner scan = new Scanner( System.in );
^
Input.java:7: cannot find symbol
symbol : class Scanner
Scanner scan = new Scanner( System.in );
^
The problem is that the Scanner class (which is in the java.util package) has not been imported. To solve the problem, change line 2 to read:
import java.util.Scanner;