3

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.

Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66

1 Answers1

5

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

M A
  • 71,713
  • 13
  • 134
  • 174