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 trialSINAN LIN
2,254 PointsPrint Jar content Question.
I can't print the Jar content here
import java.util.Scanner;
public class Prompter {
private Jar jar; //Take in value Scanner scanner = new Scanner(System.in);
public void Play(){
System.out.print("Hi, what item would you want to put in the Jar? \n ");
String item = scanner.nextLine();
System.out.print("What is the maximum number? \n ");
int number = scanner.nextInt();
//Store the value
jar = new Jar(item,number);
//Check the stored value
String mName = jar.getJarItem();
int mNumber = jar.getJarNumber();
System.out.printf("%s,%i",mName,mNumber);
}
}
1 Answer
Seth Kroger
56,413 PointsThe correct format string for a decimal integer is %d, not %i. Other than that, everything looks good.