Originally posted by Gerardo Tasistro:
- this
System.out.println("\n"+ number +line1);
System.out.println(number + line2);
System.out.println(line3);
System.out.println();
could be
System.out.println("\n"+ number +line1+"\n"+number + line2+"\n"+line3+"\n");
It could be, but it shouldn't be. Five calls
to println() is the preferred way, but if you
really want to do it in a single call I guess
you could do it like this:
String sep = System.getProperty("line.separator");
System.out.println(sep + number + line1 + sep + number + line2 + sep + line3 + sep);
or:
System.out.print(sep + number + line1 + sep + number + line2 + sep + line3 + sep + sep); // make final newline explicit
There's a good FAQ answer out there somewhere that touches
on this, but I couldn't find it when I searched briefly.