Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
51 lines (42 loc) · 2.34 KB
/
Copy pathMain.java
File metadata and controls
51 lines (42 loc) · 2.34 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
package modern.challenge;
public class Main {
private static final String LS = System.lineSeparator();
public static void main(String[] args) {
String text1 = new StringBuilder()
.append("My high school, ").append(LS)
.append("the Illinois Mathematics and Science Academy,").append(LS)
.append("showed me that anything is possible ").append(LS)
.append("and that you're never too young to think big.")
.toString();
System.out.println("--------------------------------------------");
System.out.println("Text 1:" + LS + text1);
System.out.println("--------------------------------------------");
String text2 = String.join(LS,
"My high school, ",
"the Illinois Mathematics and Science Academy,",
"showed me that anything is possible ",
"and that you're never too young to think big.");
System.out.println("Text 2:" + LS + text2);
System.out.println("--------------------------------------------");
String text3 = "My high school, " + LS
+ "the Illinois Mathematics and Science Academy," + LS
+ "showed me that anything is possible " + LS
+ "and that you're never too young to think big.";
System.out.println("Text 3:" + LS + text3);
System.out.println("--------------------------------------------");
String text4 = String.format("%s" + LS + "%s" + LS + "%s" + LS + "%s",
"My high school, ",
"the Illinois Mathematics and Science Academy,",
"showed me that anything is possible ",
"and that you're never too young to think big.");
System.out.println("Text 4:" + LS + text4);
System.out.println("--------------------------------------------");
// JDK 13 text blocks
String text5 = """My high school,
the Illinois Mathematics and Science Academy,
showed me that anything is possible
and that you're never too young to think big.""";
System.out.println("Text 5:" + LS + text5);
System.out.println("--------------------------------------------");
}
}