Reputation: 11120
I've observed that in the JShell session, not only package "java.lang", but quite a few other packages (that are not imported automatically in the Java class files, e.g. LinkedList
, Math
and several other types) seem to be imported, by default.
I wonder, what other packages are available, by default, in the JShell session, and what motivates this distinction from the normal class files?
I could not find anything on JEP 222, neither the motivation of this auto/implicit import , nor the documentation of - what is actually imported.
Upvotes: 3
Views: 235
Reputation: 72854
You can run /import
to find out:
jshell> /import
| import java.io.*
| import java.math.*
| import java.net.*
| import java.nio.file.*
| import java.util.*
| import java.util.concurrent.*
| import java.util.function.*
| import java.util.prefs.*
| import java.util.regex.*
| import java.util.stream.*
https://docs.oracle.com/en/java/javase/11/tools/jshell.html
Upvotes: 5