Content deleted Content added
No edit summary Tags: Mobile edit Mobile web edit |
|||
(8 intermediate revisions by 3 users not shown) | |||
Line 67:
== Properties of modules ==
Modules are
| url=http://openjdk.java.net/projects/jigsaw/spec/sotms/
| title=The State of the Module System
Line 99:
}}</ref> For example, the majority of the Java standard library is exported by the module <code>java.base</code>.
<syntaxhighlight lang="Java">
import java.sql.*;
Line 106:
</syntaxhighlight>
Similarly, <syntaxhighlight lang="Java" inline>import module java.base;</syntaxhighlight>, similarly, imports all 54 packages belonging to <code>java.base</code>.
<syntaxhighlight lang="Java">
import module java.base;
/**
* importing module java.base allows us to avoid manually importing most classes
* the following classes (outside of java.lang) are used:
* java.text.MessageFormat
* java.util.Date
* java.util.List
* java.util.concurrent.ThreadLocalRandom
*/
public class Example {
public static void main(String[] args) {
List<String> colours = List.of("Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet");
IO.println(MessageFormat.format("My favourite colour is {0} and today is {1,date,long}",
colours.get(ThreadLocalRandom.current().nextInt(colours.size())),
new Date()
));
}
}
</syntaxhighlight>
Modules use the following [[List of Java keywords|keywords]]:
Line 123 ⟶ 145:
{| class="wikitable plainrowheaders"
! scope="row" | {{code|java.base}}
| Defines the core APIs that form the foundation of the Java SE Platform.
Implicitly required by all modules and does not need to be declared with <code>requires</code> inside a module declaration. |-
! scope="row" | {{code|java.compiler}}
Line 291 ⟶ 314:
|-
! scope="row" | {{code|jdk.xml.dom}}
| Defines the JDK's subset of the [[World Wide Web Consortium]] (W3C) [[Document Object Model]] (DOM) API not covered by Java SE. Exports packages outside of the <code>java</code> namespace (from <code>org.w3c.dom</code>).
|-
! scope="row" | {{code|jdk.zipfs}}
Line 318 ⟶ 341:
* [[Classpath]]
* [[Java class loader]]
* [[
== References ==
Line 334 ⟶ 357:
[[Category:Java specification requests]]
[[Category:Modularity]]
|