Home  >  Article  >  Java  >  How to list all classes, interfaces and enumerations in JShell in Java 9?

How to list all classes, interfaces and enumerations in JShell in Java 9?

WBOY
WBOYforward
2023-08-31 19:49:02578browse

如何在Java 9的JShell中列出所有的类、接口和枚举?

The JShell tool introduced in Java 9 is also known as REPL(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 execute expressions, use imports, define classes, methods and >variables.

We can list all classes , interfaces and enumerations using the "/types" command in Defined 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 ".

<strong>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</strong>

In the following code snippet, use the "/types" command to list all classes and interfaces and enumerations.

<strong>jshell> /types
|   class Test
|   interface TestInterface
|   enum EnumTest
</strong>
<strong>jshell></strong>

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete