Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

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

Related Tutorials


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.


If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  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.

Posted on: May 8, 2013

Related Tutorials

Discuss: Java error cannot find symbol  

Post your Comment

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