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 trial

Java Java Basics Using your New Tools Multiple Format Strings

Kevin Frostad
Kevin Frostad
3,483 Points

Java challenge Task 3 of 3

I can't see what I'm doing wrong here.

Multiple.java
// I've imported java.io.Console for you.  It is stored in a variable called console for you.

String name = console.readLine("");
String pastTenseVerb = console.readLine("");
System.out.printf("%s really %s this coding exercise", name, pastTenseVerb);

1 Answer

You want to use console.printf()

Kevin Frostad
Kevin Frostad
3,483 Points

I see... Do you mind explaining why it doesn't work with .out? Whats the difference?

Kevin Frostad
Kevin Frostad
3,483 Points

I tried this:

String name = console.readLine("Name: "); String pastTenseVerb = console.readLine("past tense verb: "); System.printf("%s really %s this coding exercise", name, pastTenseVerb);

still doesn't work. Error message:

JavaTester.java:118: error: cannot find symbol System.printf("%s really %s this coding exercise", name, pastTenseVerb); ^ symbol: method printf(String,String,String) location: class System 1 error

System.printf("%s really %s this coding exercise", name, pastTenseVerb);

needs to be

console.printf("%s really %s this coding exercise", name, pastTenseVerb);

The task wants you to use the console object to print them out.

Kevin Frostad
Kevin Frostad
3,483 Points

Okay, thank you! Guess I'll get in on the differences later on :)