-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMainApplication.java
More file actions
91 lines (67 loc) · 2.36 KB
/
MainApplication.java
File metadata and controls
91 lines (67 loc) · 2.36 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package _005_text_blocks_multiline_strings;
public class MainApplication {
public static void main(String[] args) {
String myJSON = "{\n" +
" \"name\": \"Katerina\",\n" +
" \"username\": \"katerina\",\n" +
" \"role\": [\"user\"],\n" +
" \"password\": \"123456789\"\n" +
"}";
System.out.println(myJSON);
System.out.println("--------------------------------------");
String myJSON2 = """
{
"name": "Katerina",
"username": "katerina",
"role": ["user"],
"password": "123456789"
}
""";
System.out.println(myJSON2);
System.out.println("--------------------------------------");
String json = """
{
"id": 101,
"name": "Bob",
"skills": ["Java", "Python", "SQL"]
}
""";
System.out.println(json);
System.out.println("--------------------------------------");
String special = """
First line
Second line\nThird line (with \\n)
He said: \"Java is cool!\"
""";
System.out.println(special);
System.out.println("--------------------------------------");
String html = """
<html>
<body>
<p>Hello World.</p>
</body>
</html>
""";
System.out.println(html);
System.out.println("--------------------------------------");
String tricky = """
This is a triple quote: \"\"\"
And it's inside a text block!
""";
System.out.println(tricky);
System.out.println("--------------------------------------");
String escape = """
Before " "
Then "" and finally \"""
""";
System.out.println(escape);
System.out.println("--------------------------------------");
String name = "Bob";
String message = """
Dear %s,
Your subscription will expire soon.
""".formatted(name);
System.out.println(message);
System.out.println("--------------------------------------");
}
}