| Author |
Regarding + in string and \n .
|
WeiJie Lim
Ranch Hand
Joined: Sep 05, 2012
Posts: 68
|
|
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: 1098
|
|
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
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
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: jrebel
|
|
subject: Regarding + in string and \n .
|
|
|