This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Multiline Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multiline Strings" Watch "Multiline Strings" New topic

Multiline Strings

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hi all,
I just wanted to know whether is it possible to have a multiline String with the end quote in a saperate line.

String j = "Multiline
Like this";
Thank you very much. (with out the concatanation)

SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
But you can put new-lines into Strings. Get the platform-dependent new-line String from line.separator. Add this into the String at the desired places.

People do use "\n" for new-line, but that's not strictly portable.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
David Han

Joined: Nov 27, 2004
Posts: 1
Good!I see. Thanks,Peter.
I agree. Here's the link:
subject: Multiline Strings
jQuery in Action, 3rd edition