TheJShelltool introduced in Java 9 is also known asREPL(Read-Evaluate-Print-Loop)This allows us to execute Java code and get the results immediately. We can quickly evaluate expressions or short algorithms without having to create a new project, compile or build it. With JShell, we can executeexpressions,use imports, defineclasses,methodsand>variables.
We can list allclasses,interfacesandenumerationsusing the "/types" command inDefined in the current JShell session.
In the following code snippet, we create the "Test" class, the "TestInterface" interface and the enumeration "EnumTest" in the JShell tool".
C:\Users\User> jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> class Test { ...> public static void main(String args[]) { ...> System.out.println("TutorialsPoint"); ...> } ...> } | created class Test jshell> interface TestInterface { ...> public void sum(); ...> } | created interface TestInterface jshell> enum EnumTest { ...> TUTORIALSPOINT, ...> TUTORIX ...> } | created enum EnumTest
In the following code snippet, use the "/types" command to list all classes and interfaces and enumerations.
jshell> /types | class Test | interface TestInterface | enum EnumTest jshell>
The above is the detailed content of How to list all classes, interfaces and enumerations in JShell in Java 9?. For more information, please follow other related articles on the PHP Chinese website!