Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing "new line character " in a string

 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to store
String S ="name
city
zip"
in as string
Can someone suggest me way to do this.
thanks
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gemini Moses:
I need to store
String S ="name
city
zip"
in as string
Can someone suggest me way to do this.
thanks

String S = "name\ncity\nzip";
Might be different on Diferent OS's.
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for quick response.
However this is not solving my problem.
How can I store an "Enter character" in String for NT.
Thanks!!
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
\n is the new line character. What exactly are you trying to acheive?
 
Junilu Lacar
Bartender
Pie
Posts: 7772
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gemini Moses:
However this is not solving my problem.
How can I store an "Enter character" in String for NT. Thanks!!


I would think the solution Gregg gave works in any OS, including NT if you pass the String to System.out.println(). What exactly would "solving your problem" entail? What are you trying to do?
Junilu
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
It works for me. But of course only at the console (eg System.out.println("name\ncity\nzip")). You can't do it this way drawing to an Applet (or Panel). And sorry to say, I don't think it's possible (I'm pretty sure I read that once).
Good Luck,
-Dirk Schreckmann
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that's service! Three responses at once.
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone!!!
I got busy in some other stuff yesterday and did not get time at all to check on this.
I am sorry. It did work the way it is supposed to work. But my problem is solved with some other way.
Thanks once again to all of you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic