-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleImportStatements.java
More file actions
63 lines (53 loc) · 2.13 KB
/
Copy pathModuleImportStatements.java
File metadata and controls
63 lines (53 loc) · 2.13 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
package java24.modulestatements;
/**
* Java 24 Module Import Statements (Finalized) Demonstrates simplified syntax for importing modules
* NOTE: This feature is now finalized - no preview flag needed!
*/
public class ModuleImportStatements
{
public static void main(String[] args)
{
System.out.println("=== Java 24 Module Import Statements (Finalized) ===\n");
System.out.println("Overview:");
System.out.println("--------");
System.out.println("Module Import Statements are now a standard feature in Java 24.");
System.out.println("They simplify module declarations by allowing import statements\n");
System.out.println("Example: Module Import Statements");
System.out.println("--------------------------------");
System.out.println("""
// Old way (Java 9-23)
module com.example.app {
requires java.base;
requires java.sql;
requires java.nio.file;
exports com.example.app.api;
}
// New way (Java 24+)
import module java.base;
import module java.sql;
import module java.nio.file;
module com.example.app {
// Imported modules are available
exports com.example.app.api;
}
""");
System.out.println("\nKey Features:");
System.out.println("- Simplified module syntax");
System.out.println("- Cleaner module descriptors");
System.out.println("- Easier to read and maintain");
System.out.println("- Reduces boilerplate");
System.out.println("- Finalized feature (no preview flag needed)");
System.out.println("\nBenefits:");
System.out.println("- Cleaner module descriptors");
System.out.println("- Better readability");
System.out.println("- Easier module management");
System.out.println("- Less repetitive code");
System.out.println("- Production-ready (finalized)");
System.out.println("\nUse Cases:");
System.out.println("- Large applications with many module dependencies");
System.out.println("- Modular libraries");
System.out.println("- Applications using multiple Java modules");
System.out.println("\nNote: This feature is finalized in Java 24.");
System.out.println("No --enable-preview flag needed!");
}
}