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 Strings

Why did it give me the response in this format?

The code I used:

  String name = console.readLine("Enter your name here:  ");
  String adjective = console.readLine("Enter an adjective here:  ");
  String noun = console.readLine("Enter a noun here:  ");
  String verb = console.readLine("Enter a verb here:  ");
  console.printf("%s is very %s because %s %s all night." name, adjective, noun, verb);
}

The response I got:

treehouse:~/workspace$ java TreeStory
Enter your name here: weston
Enter an adjective here: awesome
Enter a noun here: earth
Enter a verb here: rotated
weston is the nameawesome is the adjectiveearth is the nounrotated is the verbtreehous e:~/workspace$

So, instead of filling the sentence out it gave me each part broken up. I never even typed "is the" in the code, not sure how it generated this or what I should change?

Thank you!

1 Answer

Geovanie Alvarez
Geovanie Alvarez
21,500 Points

Try to add a comma after the string before the name variable

console.printf("%s is very %s because %s %s all night.", name, adjective, noun, verb);