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

how to print sentences on separate lines java

hi this is what ive written

console.printf ("Hello" /n);

console.printf ("My name is Cooper");

2 Answers

HI coopercowley,

you can use the %n combination to start a new line.

So if you code

String name = "coopercowley";
String secondName = "treehouse";

console.printf ("Your name is %s %n and you learning at %s", name, secondName);

So the output will look like:

Your name is coopercowley
and you learning at treehouse

thanks!

You are so welcome !

Greets from germany :)