Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSven Hecker
748 PointsCannot find symbol
If i try to run the exact same code as shown in the vid at min 3:32 i got an error saying
com/teamtreehouse/override/Main.java:6: error: cannot find symbol
System.out.println(mycheese);
^
symbol: variable mycheese
location: class Main
1 error
My SDK ist set to "temurin-17" and Compiler output is defined too.
1 Answer
Steven Parker
231,268 PointsAll this error is saying is that there is an attempt to reference "mycheese" but that it has not been declared. To help identify the actual issue, we'd need to see the rest of the code, or you could share a link to a workspace snapshot.
Sven Hecker
748 PointsSven Hecker
748 PointsHi, thank you for your reply. Here is what my Main.java looks like:
and my Cheese.java:
If the problem is a missing reference, why does it work in the video though?
Steven Parker
231,268 PointsSteven Parker
231,268 PointsIt's a spelling issue. The symbol previously declared is "myCheese" (with a capital "C"), but the undefined reference is to "mycheese" (all lower case).
The working code in the video has a reference to "myCheese", spelled the same as it was declared.