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 trialConor Houston
2,441 PointsWhat is wrong with my Pez Dispenser code
public class Example {
public static void main(String[] args) { // Your amazing code goes here... System.out.println("We are making a new PEZ dispenser"); PezDispenser dispenser = new PezDispenser (Donatello); System.out.printf ("The new dispenser is %s %s", dispenser.getCharacterName() );
}
}
2 Answers
andren
28,558 PointsDonatello is a string so it has to be enclosed in quotes like this:
PezDispenser dispenser = new PezDispenser("Donatello");
If you write a word without using quotes Java will assume you are referencing a variable or something like that, so you always have to use quotes when entering some arbitrary text.
Conor Houston
2,441 PointsThanks much appreciated!