-
-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathJava15TextBlocks.java
More file actions
33 lines (28 loc) · 981 Bytes
/
Copy pathJava15TextBlocks.java
File metadata and controls
33 lines (28 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/// Expect:
/// - output: "<html>\n <body>hi</body>\n</html>\n|he said \"\"quoted\"\" ok\n|a b\tc\n"
package example;
// https://docs.oracle.com/en/java/javase/15/language/text-blocks.html
public class Program {
public static void main(String[] args) {
String html = """
<html>
<body>hi</body>
</html>
""";
// Two adjacent quotes are legal inside a text block, and require a longer
// delimiter when converted to a C# raw string literal.
String quotes = """
he said ""quoted"" ok
""";
// \s keeps a trailing space, a trailing backslash joins lines, and \t is a tab.
String escapes = """
a\s\
b\tc
""";
System.out.print(html);
System.out.print("|");
System.out.print(quotes);
System.out.print("|");
System.out.print(escapes);
}
}