如何在Java 9的JShell中打印先前键入的片段?
JShell is an official Read-Evaluate-Print-Loop (REPL) introduced in Java 9. It provides an interactive shell for quickly prototyping, debugging, and learning Java and Java API without the need for a main() method.
The "/list" command in JShell prints out all of the previously typed snippets of that particular session with a unique identifier called the snippet ID. By default, the output doesn't contain any snippet with only valid statements or expressions that can be shown. We need to see all previously typed code include errors, then pass the -all argument to the /list command.
In the below code snippet, we have created some statements like expression, class, method, and etc in JShell.
<strong>C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> int x=20 x ==> 20 jshell> "Java 9" $2 ==> "Java 9" jshell> System.out.println($2) Java 9 jshell> class Test { ...> } | created class Test jshell> void print() { ...> System.out.println("Tutorialspoint"); ...> } | created method print() jshell> print() Tutorialspoint jshell> System.out.println(x) 20</strong>
在下面的代码片段中,我们可以使用"/list"命令查看所有先前输入的代码片段。
<strong>jshell> /list 1 : int x=20; 2 : "Java 9" 3 : System.out.println($2) 4 : class Test { } 5 : void print() { System.out.println("Tutorialspoint"); } 6 : print() 7 : System.out.println(x) </strong>
以上是如何在Java 9的JShell中打印先前键入的片段?的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

Java的类上载涉及使用带有引导,扩展程序和应用程序类负载器的分层系统加载,链接和初始化类。父代授权模型确保首先加载核心类别,从而影响自定义类LOA

本文讨论了使用咖啡因和Guava缓存在Java中实施多层缓存以提高应用程序性能。它涵盖设置,集成和绩效优势,以及配置和驱逐政策管理最佳PRA

本文讨论了使用JPA进行对象相关映射,并具有高级功能,例如缓存和懒惰加载。它涵盖了设置,实体映射和优化性能的最佳实践,同时突出潜在的陷阱。[159个字符]

本文讨论了使用Maven和Gradle进行Java项目管理,构建自动化和依赖性解决方案,以比较其方法和优化策略。

本文使用Maven和Gradle之类的工具讨论了具有适当的版本控制和依赖关系管理的自定义Java库(JAR文件)的创建和使用。
