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 trialKhuzema Siamwala
Java Web Development Techdegree Student 6,517 Pointsprintln issues !
public class Example {
public static void main(String[] args) {
System.out.println(" We're making a new Pez Dispenser \n");
PezDispenser dispenser = new PezDispenser();
System.out.println("The dispenser is called %s", dispenser.mCharacter);
} }
I got a whole lot of errors when I used println while printf worked fine. My PezDispenzer class is exactly the same as Craigs.
The first error I got was no suitable method found for println(String, String); followed by a whole list of others..
2 Answers
Kourosh Raeen
23,733 PointsYou get errors because there is no println() method that takes two arguments. You need to use printf() for that last statement:
System.out.printf("The dispenser is called %s", dispenser.mCharacter);
Fernando Flores
Python Web Development Techdegree Student 720 PointsI was getting the same errors, even with printf. This is what I did. Not sure if it's correct, I'm a newbie with Java.
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();
System.out.println("The dispenser character is " + dispenser.mCharacterName);
}
}
Michael Bishara
1,911 PointsMichael Bishara
1,911 PointsThank you so much!