wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes new line character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "new line character" Watch "new line character" New topic
Author

new line character

Ken Anderson
Greenhorn

Joined: Nov 24, 2000
Posts: 6
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
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
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

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
See what a difference makes posting a little code
Ken Anderson
Greenhorn

Joined: Nov 24, 2000
Posts: 6
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
Thank You Val and David. Posting code does make a difference doesn't it?
 
GeeCON Prague 2014
 
subject: new line character