Author
new line character
Ken Anderson
Greenhorn
Joined: Nov 24, 2000
Posts: 6
posted May 14, 2001 23:12:00
0
I have no problem using the println() function when needed, but cannot get the newline character \n to work. Each attempt to use it, the compiler says "invalid character". This happens no matter where I insert it, front, middle or end of a sentence. Any suggestions?
Val Dra
Ranch Hand
Joined: Jan 26, 2001
Posts: 439
posted May 14, 2001 23:24:00
0
is it included as a part of a string ? can you show your code ?
Val SCJP <BR>going for SCJD
Ken Anderson
Greenhorn
Joined: Nov 24, 2000
Posts: 6
posted May 14, 2001 23:51:00
0
if ( count >= 56 ) \nSystem.out.print( args.[i] ) ; above gives invalid character. if ( count >= 56 ) System.out.println( args.[i] ) ; above works fine except newline comes after i is printed
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
posted May 15, 2001 00:44:00
0
The line you have that doesn't work isn't printing the newline. You need to include it in the string that is output... or even better (since the newline character is system dependant)... or if you're looking for a third answer: Dave. [This message has been edited by David O'Meara (edited May 15, 2001).]
Val Dra
Ranch Hand
Joined: Jan 26, 2001
Posts: 439
posted May 15, 2001 07:02:00
0
See what a difference makes posting a little code
Ken Anderson
Greenhorn
Joined: Nov 24, 2000
Posts: 6
posted May 15, 2001 12:26:00
0
Thanks a bunch Val and David. That works great. I see what you mean about a little bit of code. It does kind of show where the error is right away.
Ken Anderson
Greenhorn
Joined: Nov 24, 2000
Posts: 6
posted May 15, 2001 12:45:00
0
Thank You Val and David. Posting code does make a difference doesn't it?
subject: new line character