Java 13 — New Language Features

Text Blocks (Preview) (JEP 355)

text includes multiple lines 
and symbols like " or ' or \
String text = "text includes multiple lines " +
"\nand symbols like \" or \' or \\";
<html>    <head>
</head>
<body>
<p align="center">Hello</p>
</body>

</html>
String htmlText = "<html>\n\n" +
"\t<head>\n" +
"\t</head>\n" +
"\t\n" +
"\t<body>\n" +
"\t\t<p align=\"center\">Hello</p>\n" +
"\t</body>\n" +
"\t\n" +
"</html>";
String text = """
text includes multiple lines\s
and symbols like " or ' or \\
""";
String textHtml = """
<html>
<head>
</head>

<body>
<p align="center">Hello</p>
</body>

</html>
""";
"""
triple quotes.
"""

Final notes:

  """
<html>
<body>
</body>
</html>
""";
..<html> <!-- does represent spaces -->
<body>
</body>
</html>

Switch Expressions (Second Preview) (JEP 354)

int month = 1;String name = switch (month) {
case 1 -> {
break "Giorgi";
}
default -> {
break "Other name";
}
};
System.out.println(name);
int month = 1;String name = switch (month) {
case 1 -> {
yield "Giorgi";
}
default -> {
yield "Other name";
}
};
System.out.println(name);

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Giorgi Tsiklauri

Giorgi Tsiklauri

Engineer, trainer, long while w/ music, computers, software engineering/architecture; interested in computer networks, composition, security, privacy, climate.