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

Create a new variable called name and accept input from the console using the readLine method.

Create a new variable called name and accept input from the console using the readLine method.

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

i don't when i wrote the same thing it didn't work but when i copied your code it worked :)

4 Answers

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

This is an older post & an older reply, but I do think that the current wording of the code challenge: "Create a new variable called name and accept input from the console using the readLine method" should produce the result:

String name = console.readLine;

which results in an error but I'm not clear why and what the error means.

For some reason when I write the same code it doesn't work but when I copy and past, it does work :)

(1) String name = console.readLine("Enter your name: ");

(2) String pastTenseVerb = console.readLine("Enter a past tense verb: ");

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

Hey Jules,

Can you explain where you're stuck on this challenge?

Best,

Jacob

String name = console.readLine("enter your name "); console.printf( "%s", name);