Output Related... System.out.print vs System.out.println

Write here if you have problems with your Java source code

Moderator: Board moderators

Post Reply
wyanez
New poster
Posts: 8
Joined: Thu Nov 20, 2003 7:19 pm

Output Related... System.out.print vs System.out.println

Post by wyanez »

What believe you... who are better and/or efficient (fast and
optimal):
System.out.println("result is" +r);
or
System.out.print("result is");
System.out.println(r);


I say it, because the compiler translates
System.out.println("result is" +r);
thus :
System.out.println(new StringBuffer(" result is").append(String.valueOf(r).toString());

what implies: creation of new objects, calls to methods, etc...
So what you do think?[/b]
Post Reply

Return to “Java”