[JAVA] The right way for Line Breaks
Questions/Tutorials for any programming language not covered in other sections.
2 posts
Page 1 of 1
Hey guys,
Introduction
In this JAVA tutorial we will see how to make line breaks in the right way.
Old methods
Actually not OLD methods they are still used but when it comes to Cross Platform they doesn't work.
beginners use for line breaks :
actually it works but one thing every java programmers should know; if you use "\n" it can only work on Windows so it's a big problems and by the way on Mac for a line break in java you must use "\r" and on Linux it's"\r\n".
Now if you want to make a line break that works on all platforms(Windows, Mac, Linux etc), there's a way.
Make a public string(this line should be placed before the main event like C#)
After a longtime wrote a tutorial on C'N'S( ..and testing my right hand lol) If you find this helpful don't forget give a +REP.
PS : don't mind my bad english lol
Introduction
In this JAVA tutorial we will see how to make line breaks in the right way.
Old methods
Actually not OLD methods they are still used but when it comes to Cross Platform they doesn't work.
beginners use for line breaks :
Code: Select all
System.out.println("\n");
actually it works but one thing every java programmers should know; if you use "\n" it can only work on Windows so it's a big problems and by the way on Mac for a line break in java you must use "\r" and on Linux it's"\r\n".
Now if you want to make a line break that works on all platforms(Windows, Mac, Linux etc), there's a way.
Make a public string(this line should be placed before the main event like C#)
Code: Select all
Now whenever you want to make a line break all you have to do is print the string lol
public static String newline = System.getProperty("line.separator");
Code: Select all
It will make a line break and it will work on all java supported platforms.System.out.println(BR);
After a longtime wrote a tutorial on C'N'S( ..and testing my right hand lol) If you find this helpful don't forget give a +REP.
PS : don't mind my bad english lol
Find my programs on Softpedia
2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023