Skip to content

Commit 71f43d1

Browse files
author
Araf Karsh Hamid
committed
Added Java 15 Examples
1 parent 5f11ffc commit 71f43d1

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

src/java15/TextBlockExample.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Copyright (c) 2024 Araf Karsh Hamid
3+
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
11+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17+
* THE SOFTWARE.
18+
19+
* This program and the accompanying materials are dual-licensed under
20+
* either the terms of the Eclipse Public License v1.0 as published by
21+
* the Eclipse Foundation
22+
23+
* or (per the licensee's choosing)
24+
25+
* under the terms of the Apache 2 License version 2.0
26+
* as published by the Apache Software Foundation.
27+
*/
28+
package java15;
29+
30+
/**
31+
* Java 15 Example
32+
* Text Block Example
33+
*
34+
* @author: Araf Karsh Hamid
35+
* @version:
36+
* @date:
37+
*/
38+
public class TextBlockExample {
39+
40+
public static void main (String[] args) {
41+
// Java 15
42+
System.out.println("JAVA 15 >>>>>--------------------------------------------------------");
43+
System.out.println("Text Block Example - with Text Formatting maintained");
44+
String multiLineData = """
45+
This is the 1st line.
46+
This is the line 2.
47+
2.1 This is a sub line of Line 2
48+
2.2 This is a sub line of Line 2
49+
This is the line 3.
50+
This is the last line.
51+
""";
52+
System.out.println("Multi-Line Text Data >> ");
53+
System.out.print(multiLineData);
54+
55+
System.out.println("Text Block Example - Parametrized");
56+
String profileTemplate = """
57+
First Name: %s
58+
Last Name: %s
59+
Age: %d
60+
City: %s
61+
Country: %s
62+
""";
63+
System.out.println("Multi-Line Profile Template >> ");
64+
System.out.print(profileTemplate.formatted("Jane", "Doe", 23, "Denver", "USA"));
65+
}
66+
}
67+

0 commit comments

Comments
 (0)