如何在 Java 9 中在 JShell 中設定詳細模式?
JShell 是 Java 9 中引入的 REPL 工具。我們可以使用此工具在命令列提示符中執行簡單的程式碼段。
當我們在 JShell 中輸入算術表示式、變數等時,它會顯示結果,但不顯示建立的變數的型別詳細資訊。可以在 JShell 中顯示有關執行輸入命令的更多資訊,使用詳細模式。我們需要使用命令來獲取有關使用該命令執行的更多資訊:“/set feedback verbose”(該命令可以前置“/”)。
在下面的程式碼段中,詳細模式已開啟,並且它能夠顯示有關變數型別的更多資訊。
C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> /set feedback verbose | Feedback mode: verbose jshell> 5.0 * 8 $1 ==> 40.0 | created scratch variable $1 : double jshell> String str = "TutorialsPoint"; str ==> "TutorialsPoint" | created variable str : String jshell> void test() { ...> System.out.println("Tutorix"); ...> } | created method test() jshell> test() Tutorix jshell> String str1 = new String("Tutorix"); str1 ==> "Tutorix" | created variable str1 : String jshell> "TutorialsPoint" + "Tutorix" + 2019 $6 ==> "TutorialsPointTutorix2019" | created scratch variable $6 : String jshell> int test1() { ...> return 10; ...> } | created method test1() jshell> test1() $8 ==> 10 | created scratch variable $8 : int
廣告