Home Java Java-get-example Java error cannot find symbol
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java error cannot find symbol

Advertisement
Java cannot find symbol occur when compiler has not enough information about what java code trying to execute.

Java error cannot find symbol

In this section you will learn about "cannot find symbol" in java. Java cannot find symbol is a type of error occurs when a compiler has not enough information about the variable, class or method name  you used in program. When a java program is being compiled then compiler create a list of variables in use. If it can't find the variable in use its trying to refer, then it will give a error cannot find symbol.

Reason for cannot find symbol is as follows:

  • When trying to use a variable without declaring it.
  • Misspelling of class or method name.
  • Package class used has not being referenced correctly using import declaration.
  • When parameter used do not matched in method signature.

Example : The following code illustrates what is cannot find symbol :

    public class CannotFindSymbol {
   public static void main(String args)
  {
   int a,b;
   System.out.printl("value of a"+a);
   }
}

Output : When you compile and execute the program output will be as below

Description : In the above program system.out.println() will confuse compiler and give error cannot find symbol because System.out class does not have method "printl"

Advertisements

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: June 10, 2013

Ask Questions?    Discuss: Java error cannot find symbol  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com