File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Regarding + in string and \n . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding + in string and \n ." Watch "Regarding + in string and \n ." New topic
Author

Regarding + in string and \n .

WeiJie Lim
Ranch Hand

Joined: Sep 05, 2012
Posts: 85


The above code will result in :
Welcome to the voting machine error code decoder.

If your voting machine generates an error code,
you can use this program to determine the exact
cause of the error.

However, I decide to remove all the + . I didn't think it is neccessary.. or am I wrong. Nevertheless, I tried and the result is really different. Why is this so ?
I tried :


Resulted in :
Welcome to the voting machine error code decoder.
If your voting machine generates an error code,
you can use this program to determine
the exact
cause of the error.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

to be honest I am suprised it compiled, when i cut and paste it into eclipse


it didn't compile. So any results you get are completely random, as strings are not meant to go over line ends (wrap).
That is what all the + are for
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

WeiJie Lim wrote:However, I decide to remove all the + . I didn't think it is neccessary.. or am I wrong.

You can do that but then you would need to write the whole string on one line, otherwise you will get compiler errors, as Wendy tried. Java does not allow you to open a string literal on one line and close it on another line.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding + in string and \n .
 
Similar Threads
StackOverflowError
Recursion Formula
Hello guys, kindly help me on this problem
NX: closing of the application (System.exit(0), System.exit(n))
So, which of these would be...