A newline is represented by \n and a carriage return by \r. UNIX only seems to recognize the newline:
UNIX > cat prog24.java
public class prog24
{
public static void main (String args[])
{
System.out.println("Newline->\n");
System.out.println("Carriage return->\r");
}
}
UNIX > javac prog24.java
UNIX > java prog24
Newline->
Carriage return->
UNIX >
If you copy the program to a Windows environment and run it in a command prompt, both characters are recognized:
C:\Users\J0294094\Java>java prog24
Newline->
Carriage return->
C:\Users\J0294094\Java>
If
you have a Java book on Amazon, which you would like to advertise here
for free, please write to me at international_dba@yahoo.co.uk.