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 trialJoseph Nickalo
432 Pointsconsole.printf("I need help with the Pez Dispenser.")
Hello, I´m doing the pez challenges again to review, and I´ve got the Example and PezDispenser files filled out but the compiler wont work and i don´t understand what it´s telling me. any help?
-Example.java- 1) public class Example 2) public static void main(String[] args) { 2) System.out.println("Woo a new pez thing is on the way!"); 4) PezDispenser pez = new PezDispenser("Bob"); 5) System.out.println("The new pez thing will be called %s\n", pez.getCharacterName()); 6) } 7) }
-PezDispenser.java-
1) public class PezDispenser {
2) private String mCharacterName;
3)
4) public PezDispenser (String characterName) {
5) mCharacterName = characterName;
6) }
7)
8) public String getCharacterName() {
9) return mCharacterName;
10) }
11) }
1 Answer
Craig Dennis
Treehouse TeacherThis line:
System.out.println("The new pez thing will be called %s\n", pez.getCharacterName());
Should be using printf
for printing formatted code.
Joseph Nickalo
432 PointsOOOhh I remember you mentioning that now
Admire Dhodho
5,411 PointsAdmire Dhodho
5,411 Pointscan you upload your code in the workspace format and copy and paste the question as it is