
JShell 工具已经在Java 9 版本中引入。它也被称为REPL(Read-Evaluate-Print-Loop)工具,允许我们执行Java代码并立即获得结果。我们可以使用"/types"命令列出声明的类型,如class、interface、enum等。
以下是JShell中不同的"/types"命令。
<strong>/types /types [ID] /types [Type_Name] /types -start /types -all</strong>
在下面的代码片段中,创建了类,接口和枚举类型。然后,我们可以应用不同的"/types"命令。
<strong>jshell> enum Operation {
...> ADDITION,
...> DIVISION;
...> }
| created enum Operation
jshell> class Employee {
...> String empName;
...> int age;
...> public void empData() {
...> System.out.println("Employee Name is: " + empName);
...> System.out.println("Employee Age is: " + age);
...> }
...> }
| created class Employee
jshell> interface TestInterface {
...> public void sum();
...> }
| created interface TestInterface
jshell> /types
| enum Operation
| class Employee
| interface TestInterface
jshell> /types 1
| enum Operation
jshell> /types -start
jshell> /drop Operation
| dropped enum Operation
jshell> /types -all
| enum Operation
| class Employee
| interface TestInterface</strong>以上就是在Java 9的JShell中,有哪些不同的"/types"命令?的详细内容,更多请关注php中文网其它相关文章!
java怎么学习?java怎么入门?java在哪学?java怎么学才快?不用担心,这里为大家提供了java速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号