Home > Java > javaTutorial > body text

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

WBOY
Release: 2023-08-31 19:49:02
forward
591 people have browsed it

如何在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>
Copy after login

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>
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template