String literals must be enclosed in quotation marks.1 This error occurs if you fail to
terminate the literal with quotation marks. Fortunately, the syntax of JAVA requires
that a string literal appear entirely on one line so the error message appears on the
same line as the mistake. If you need a string literal that is longer than a single line,
create two or more literals and concatenate them with +:
String longString = "This is first half of a long string " + "and this is the second half.";
ECLIPSE: String literal is not properly closed by a double-quote. In ECLIPSE you
can write a string literal of arbitrary length and the environment will break the string
and insert the + automatically.
1A literal is a source-code representation of a value; most literals are of primitive types like int or char, but there are also literals of type String and the literal null of any reference type.
No comments:
Post a Comment