Java error cannot find symbol

The java error cannot find symbol occurred when a Compiler does not recognize a class name.

Java error cannot find symbol

Java error cannot find symbol

     

The java error cannot find symbol occurred when a Compiler does not recognize a class name. The following are the reason for such an error  -

1)When a programmer misspelled the name of the class.

2When a programmer do not Imported the class name.

In this Tutorial we want to describe you a code that help you in understanding java error cannot made symbol. For this we have a class name 'cannot find symbol'. Inside the main method we have initialized a int variable a and b with respective values and store the sum of the value in variable int d.The System.out.println. is used to print the output  in variable d in the try block. But in this code the programmer misspelled the variable.,inspite  of writing d,the programmer write variable e,The catch block helps you in handling the error occurred in the try block. Therefore  the compiler does not recognize a variable e show you an error Java error cannot find symbol.

Here is the video tutorial of "How to solve cannot find symbol error in Java?":

Cannotfindsymbol.java
import java.lang.*;
public class Cannotfindsymbol {

  
  public static void main(String[] args) {
 try{
  int a=10;
 int b=3;
 
 int d=a+b;
 System.out.println(e);
  }
  catch(Exception ex){
  System.out.println(ex);
  }
  }
}

Output
/home/girish/NetBeansProjects/errors/src/
Cannotfindsymbol.java:
11: cannot find symbol

symbol  : variable e
location: class Cannotfindsymbol
  System.out.println(e);
error0

To remove this error you have to declare the variable e.

Download code