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 While Loops

What is the differences between %n and /n ?

We use /n for new line in,

if (age < 13) {
          console.printf("Sorry you must be 13 to use this program\n");

but we use %n for new line in,

while (noun.equalsIgnoreCase("dork")||
               noun.equalsIgnoreCase("Jerk")){
          console.printf("Not allowed!!! %n");

What is the difference?

1 Answer

Hi there,

The %n formatter is platform-specific so is the preferred one of the two.

Have a read through the table here for more info.

Steve.