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
497 people have browsed it

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

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

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>
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!