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 (Retired) Meet Objects Creating Classes

Lawrence McBride
Lawrence McBride
39 Points

What is wrong with my code?

From what I can see my code matched what Craig has on the screen in the video however, I keep getting this error message: location: Class Example Example.java:6: error: cannot find symbol PezDispenser dispenser = new PezDispenser ();

With an arrow under the "P" in new PezDispenser

Victor Learned
Victor Learned
6,976 Points

Please post your code otherwise we won't be able to help.

6 Answers

In the toolbar on the right, right click on Pez Dispenser.java, press rename, and erase the space.

Lawrence McBride
Lawrence McBride
39 Points

Oh, in the actual name of the file! Thanks for your help!

Always happy to help!

I could take a look if you post the whole code.

Lawrence McBride
Lawrence McBride
39 Points

System.out.println("We are making a new Pez Dispenser."); PezDispenser dispenser = new PezDispenser(); System.out.Printf("The dispenser character is %s\n", dispenser.mCharacterName);

Try erasing the space in PezDispenser ();.

Lawrence McBride
Lawrence McBride
39 Points

I've tried it with and without a space in there, it comes back with the same error message unfortunately.

Can I see your workspace? Just click the picture of a camera in the upper right corner and press Take Snapshot :camera:. Then, press the photo you made, copy the link, and paste it here.

Erase the space in between Pez and Dispenser, and by the way what you did was called a Snapshot.

Lawrence McBride
Lawrence McBride
39 Points

Unfortunately at the moment the the only place there is a space in between Pez and Dispenser is in the System.out.println.