Java Reference
In-Depth Information
By enclosing the string in single quotes, you do not have to escape the embedded
double quotes. Consider the following two examples, which are both valid:
var quote = "Winston Churchill said:
\"Never in the field of human conflict was
so much owed by so many to so few.\""
var quote = 'Winston Churchill said:
"Never in the field of human conflict was
so much owed by so many to so few."'
Expressions can be embedded within the string literal by using curly braces:
var name = "Jim";
// prints My name is Jim
println ( "My name is {name}" );
The embedded expression must be a valid JavaFX or Java expression that returns
an object. This object will be converted to a string using its toString() method.
For instance:
println ( "Today is {java.util.Date{}}" );
var state ="The state is {
if(running) "Running" else "Stopped"}";
println(" The state is {getStateStr()}" );
println("The state is {
if(checkRunning()) "Running" else "Stopped"}");
Also, a string literal may be split across lines:
var quote = "Winston Churchill said: "
"\"Never in the field of human conflict was so much owed "
"by so many to so few.\"";
In this example, the strings from both lines are concatenated into one string.
Only the string literals within the quotes are used and any white space outside of
the quotes is ignored.
Unicode characters can be entered within the string literal using \u + the four
digit unicode .
var thanks = "dank\u00eb"; // dankë
Search WWH ::




Custom Search