Net-informations.com
SiteMap  | About    

Compiler Error: cannot find symbol

The "Cannot find symbol" errors generally occur when you try to reference an undeclared variable in your code. A "Cannot find symbol" error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn't understand.

When your code is compiled, the compiler needs to work out what each and every identifier in your code means. As the compiler is going through the code it will find something and know what to do with it or not. Your Cannot find symbol error relates to the identifiers and means that Java cannot figure out what the "symbol" means.

Example

output

In the above code, the variable sum has not been declared, you need to tell the compiler what the type of sum is; for example:

The general causes for a Cannot find symbol error are things like:

  1. Incorrect spelling.
  2. Wrong case. Halo is different from halo.
  3. Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.
  4. No variable declaration or variable is outside of the scope you are referencing it in.









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.