cannot find symbol string java code example
Example: cannot find symbol java
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.
The general causes for a Cannot find symbol error are things like:
- Incorrect spelling.
- Wrong case. Halo is different from halo.
- Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.
- No variable declaration or variable is outside of the scope you are referencing it in.