Share on Google+Share on Google+

Java error cannot find symbol

Whenever a Compiler does not recognize a class name, Java displays an error ?cannot find symbol?.

Whenever a Compiler does not recognize a class name, Java displays an error “cannot find symbol”.

The reason behind cannot find symbol error is:

  • A programmer has misspelled the name of the class.
  • A programmer didn’t Imported the class name.

Following example will help you understand the java error cannot find symbol. In this example a class name 'cannot find symbol' is used.

int variable “w” and “x” with respective values have been initialized. int “y” stores the sum of their value.

The System.out.println is used to print the output. But programmer instead of writing “y”, wrote variable “z”.

The compiler did not recognize a variable “z” and displays an error “Java error cannot find symbol”.

import java.lang.*;
public class Cannotfindsymbol {
public static void main(String[] args) {
int w=10;
int x=3;
int y=w+x;
catch(Exception ex){


/home/girish/NetBeansProjects/errors/src/ cannot find symbol

symbol: variable z
location: class Cannotfindsymbol
1 error0

*To remove this error you have to declare the variable z.



Posted on: May 8, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Java error cannot find symbol  

Post your Comment

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