How To Make a Line Break/New Line in Java

How To Make a Line Break/New Line in Java
Line Break or New Line : I hope you understand what it is, in HTML you use <br> tag to make a new line so in Java if you want to make a new line it's not that hard but it has several methods depends on the platform.

Coming to the point, most of the java beginners think this is the one and only way to make a new line : System.out.println("\n"); but It's not true.. let me tell you something you might think that whatever you program using java will work on other java supported platforms, YES! they will work on other platforms but there are few things that has to be changed in order to get the functions work.. for example this tutorial; this line of code : System.out.println("\n"); would make a new line only on Windows. As I said before there are few things that are different from platform to platforms.

If you want to make a new line on Mac you must use this : System.out.println("\r"); and for Linux you have to use this : System.out.println("\r\n");. So I came up with something that works on all the platforms, It's pretty simple and works perfectly.

First you need to make a public string and set the value to make a new line(You can also just make normal string and set the value)
Add this line of code before your main event
public static String breakline = System.getProperty("line.separator");

Whenever you need to make a new line just use this line of code 
You can add this wherever you want to
System.out.println(breakline);

Please comment if you have any doubts..!

60 comments


Looking for a career in technology industry? Wonder what are the languages that will give just the right start to your career?
Over to the hottest programming languages you can learn in 2015.

Corporate Training

Reply

The information you have deliver here is really useful to make my knowledge good. Thanks for your heavenly post. It is truly supportive for us and I have accumulated some essential data from this blog.
Regards,
sas training in Chennai|sas course in Chennai|sas training institute in Chennai

Reply

Hi, This is really nice blog. You have done really great job. Keep posting. I did Java Training in Chennai at TIS academy. Its really useful for me to make a bright future in IT industry.

Reply

Thanks for sharing this niche useful informative post to our knowledge, Actually SAP is ERP software that can be used in many companies for their day to day business activities it has great scope in future.
Regards,
SAP training in chennai|SAP course in chennai|SAP Training in Chennai|sap training in Chennai

Reply

Awesome Post! I like writing style, how you describing the topics throughout the post. I hope many web reader will keep reading your post at the end, Thanks for sharing your view.
Regards,
Angularjs training in chennai|Angularjs training chennai|Angularjs course in chennai|Angularjs training center in Chennai

Reply

most useful information article,
great posting it author,
learn seo and complete digital marketing course with our best seo experts
seo training in bangalore

Reply

Dear admin, The way you have explained the concept is mezmerizing. Thank you so much for sharing tis worth able content with us. The concept taken here will be useful for my future programs and i will surely implement them in my study. Keep blogging article like this.


JAVA Training in Chennai | Best JAVA Training in Chennai | Android training in chennai

Reply

Hello,

The great article on Java to Make a Line Break/New Line

Java Online Course | Java Training in Chennai | J2EE Training in Chennai

Reply

Great article.I learned some new concept. Thanks for sharing.
Web designing training in chennai

Reply

Really great post thanks for fabulous sharing and also informative IOS Design And Development

Reply

Thank you for sharing this knowledge in a blogpost.Really simple and even more effective and this worked great, very useful tips
http://hadooptraininginhyderabad.co.in/salesforce-training-in-hyderabad/

Reply

Nice post. I learned new information, Thanks for sharing.

digital marketing training institute in chennai

Reply

Your blog is really very informative and useful for us. Core Java Training | Oracle DBA Training | Dot Net Training

Reply

100% Job Oriented R Programming for more Information click to the best php training in chennai

Reply

100% Job Oriented R Programming for more Information click to the best uml training in chennai

Reply

Great article. Happy to visit your blog.


Reply

I think this is a right place to begin my career successfully. because, here i found lots of best training institute in Bangalore. I believe that will give huge supports to me.

Reply

Nice tutorial about java programming. Its very authenticate for fresh web developers They can learn huge things about Java from here.
cheap MLM software

Reply

Nice Post
Thanks for giving such useful information about Java,

Dot net training institute in bangalore

Reply

Nice blog. If anyone interested to learn SAS Training visits GangBoard. We are the best provider of SAS Online Training | Data Science with R Training | Data Science with Python Training | Hadoop Training

Reply

Good information!! Really it will be more useful for the freshers. We are also one of the best sources to learn Selnium -Selenium testing training in Chennai | Best Selenium training center in Chennai

Reply

Hello admin, Java is an object oriented language and you have shared new line break java concepts. It was really great. Continue sharing more new concepts like this.
Regards,
Spring Training in Chennai | Hibernate Training in Chennai | Struts Training in Chennai

Reply

Greatest article blogs posting!! One of the best useful blog We've noticed this particular subject information is good. find selenium jobs in hyderabad.

Reply

Thanks to give such a useful information about JAVA Training in Bangalore

Reply

Very interesting and informative article to sharing the knowledge about the systems.keep rocking..
No.1 Java Project Center in Chennai | Best Dot Net Projects in Chennai | Best Mini Project Center in Chennai


Reply

Great post.
It really helped me to learn something new. So thanks.
Spring training in Bangalore.

Reply

Energetic information I got from this blog. Thanks to show me the real benefits of java programming. From here, I have realized that programming how is helpful to make mobile application. Web application projects

Reply

Thanks to afford nice programming tutorial about java. I am not expect this information from your side. But, its really valuable to me. I never forget your good work.
java training center

Reply

Thanks for sharing this wonderful blog.. it helps me a lot. best informatica training in bangalore

Reply
This comment has been removed by the author.
This comment has been removed by the author.

useful post for beginner java programmer it would improves programming logical thinking i am always eager to learn android application development Programming thus give bit more updates bout printing concepts thanks a lot.

Reply

i have read your post very informative blogs for beginners keep sharing
java programming training

Reply

Your post is outstanding! thanks for such a post, its really going great work.
AngularJS Training in Chennai | AngularJS Training Institute in Chennai

Reply

Thanks for the blog and it is really very useful one.
AWS Training in Chennai

Reply

Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
aws training institute in bangalore

Reply

This post is really really nice explained by professional manner,so thanks for your present here.
Python Training in Chennai
Python online training

Reply

Astounding post!!! Java is most well known and proficient programming dialect accessible in the market today. It encourages designers to make shocking work area/web applications stacked with staggering functionalities.

Devops Training Online

Reply

hello sir,
thanks for giving that type of information.
digital marketing company in delhi

Reply

Wow, Nice blog. Thank you so much for the efforts of this blog. Visit for
Website Development Company in Delhi

Reply

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.
Read more : R Programming institutes in Chennai | R Programming Training in Chennai

Reply


Great efforts put it to find the list of articles which is very useful to know, Definitely will share the same to other forums. big data training in Velachery | Hadoop Training in Chennai | big data Hadoop training and certification in Chennai | Big data course fees

Reply

An interesting topic with great examples, keep updating your knowledge with us. Networking Course in Chennai

Reply

I’d love to be a part of group where I can get advice from other experienced people that share the same interest. If you have any recommendations, please let me know. Thank you.

AWS Training in Chennai

Reply

Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.
lenovo service center
lenovo mobile service center near me
lenovo mobile service centre in chennai

Reply
This comment has been removed by the author.
This comment has been removed by the author.

Post a Comment

Note: Only a member of this blog may post a comment.