954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

what are the different between println and \n

anyone answer me?:@

kelvin924
Newbie Poster
4 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

println is a method.
'\n' is a character.

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

and println will not print \n on most operating systems (it will print either \n, \r, \r\n, or \n\r on most depending on system definitions).

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

To get the appropriate "\n", "\r" or "\r\n" (or other!) string for your platform, see...
http://stackoverflow.com/questions/207947/java-how-do-i-get-a-platform-independent-new-line-character

JeffGrigg
Posting Whiz in Training
218 posts since Aug 2011
Reputation Points: 192
Solved Threads: 28
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You