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 無盡。

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

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

Dreamweaver Mac版
視覺化網頁開發工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器