Home Java Java-get-example Java error cannot find symbol



Java error cannot find symbol
Posted on: November 3, 2008 at 12:00 AM
The java error cannot find symbol occurred when a Compiler does not recognize a class name.

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.

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

Related Tags for Java error cannot find symbol:
javacerrorcomcompilerclassfindcompilenamepilmpisymboleilnotcaninnoasmcajclespimedowhensannccvazssthavbolfinndomolo


More Tutorials from this section

Ask Questions?    Discuss: Java error cannot find symbol   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.