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 trialLeonard Isaksson
7,355 PointsWhat is the problem with this code?
public void addItem(Product item)
{
System.out.printf("%s",item.getName());
}
I am geting this message.
Did you uncomment the line in Example.java? The output from System.out does not show the 1 Yoda PEZ dispenser
3 Answers
jason phillips
18,131 PointsMake sure you uncomment
cart.addItem(dispenser);
from Example.java
Leonard Isaksson
7,355 PointsI have uncomment that line
jason phillips
18,131 Points public void addItem(Product item) {
System.out.printf("Adding %d of %s to the cart.%n", 1, item.getName());
}
The only way this differs is that I am also logging a 1 because this assumes that only 1 is being added when addItem is called.
Christian Lawrence
3,941 Pointsjason phillips I had the same problem. Do you know why this would be invalid? Or would it have just been bad practice?
public void addItem(Product item) {
System.out.printf("Added 1 %s to the cart.%n", item.getName());
}
Leonard Isaksson
7,355 PointsThank you it worked