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 trial

Java Java Objects Harnessing the Power of Objects Abstraction at Play

Cannot find symbol

I am having issues with Jshell while the isEmpty method is executed. I created a new pez dispenser called "Yoda" but then when I tried to execute that method is displaying this error message : jshell> pd.isEmpty();
| Error:
| cannot find symbol
| symbol: method isEmpty()
| pd.isEmpty();
| ^--------^

My method is the following: public boolean isEmpty(){ return pezCount == 0;

I don't know where the issue is, what it could be?

Can you share a snapshot of your workspace?

AFJNIK hassan
AFJNIK hassan
11,416 Points

i don't have any idea how it looks your code but "can't find symbol" mean that the function your try to call is unknown

ex: Object shape;

shape.isEmpt(); this will trow an error because isempty is not exit till you instantiate the Object with new key

1 Answer

For anyone else reading this. If you get this error, you need to be sure that you go back into your class again in jshell by simply typing /open PezDispenser.java and then re-running pd.isEmpty();