在JShell工具中执行操作时,会在return中显示一条消息(命令成功、错误、操作类型)创建的变量及其值)。它已使用以下命令进行自定义: “/set Feedback”。此命令显示当前配置的返回类型以及可用的不同返回模式。
<strong>jshell> /set feedback | /set feedback normal | | Available feedback modes: | concise | normal | silent | verbose</strong>
JShell 中有四种反馈模式,如下所示:
1) /set反馈正常:这是默认JShell 反馈。当我们计算表达式时,JShell 返回相应的结果以及存储该值的内部变量。在变量创建的情况下,JShell 返回变量的名称和相应的值。创建数据类型(方法或类)时,JShell 会发送一个返回值,指定我们创建的类型。
<strong>jshell> /set feedback normal | Feedback mode: normal jshell> 5 + 5 $1 ==> 10 jshell> int i = 20 i ==> 20 jshell> int sum(int a, int b) { ...> return a + b; ...> } | created method sum(int,int)</strong>
2) /set feedback verbose: 这是最具有信息性的反馈模式。在评估指令时,它会显示相应的结果,以及被赋值的内部变量和表达式的类型。对于变量的创建也是如此。至于数据类型的创建,返回结果与正常模式相同。
<strong>jshell> /set feedback verbose | Feedback mode: verbose jshell> 2 + 2 $1 ==> 4 | created scratch variable $1 : int jshell> String str = "Tutorix" str ==> "Tutorix" | created variable str : String jshell> int div(int a, int b) { ...> return a/b; ...> } | created method div(int,int)</strong>
3) /set feedback concise: 这种模式显示最小的信息量。在评估表达式时,它告诉我们创建的内部变量的名称以及表达式的结果。另一方面,关于数据类型(变量、方法或类)的创建,JShell 不会返回任何结果(除非代码有错误)。
<strong>jshell> /set feedback concise jshell> 2 + 2 $1 ==> 4 jshell> int i = 10; jshell> float y = "xyz"; | Error: | incompatible types: java.lang.String cannot be converted to float | float y = "xyz"; | ^---^</strong>
4) /set feedback silent: 这种模式不显示任何信息。当我们输入一个表达式进行求值时,JShell会将结果存储在一个内部变量中,但不会在屏幕上显示相应的结果。对于数据类型(变量、方法或类)的创建也是如此。所有的操作都在内部完成,不会在屏幕上显示任何结果(除非出现错误)
<strong>jshell> /set feedback silent -> 3+3 -> int x = 7 -> int sum(int x, int y) { >> return x + y; >> } -> double y = "abc"; | Error: | incompatible types: java.lang.String cannot be converted to double | double y = "abc"; | ^---^ -></strong>
The above is the detailed content of What are the different feedback modes for JShell in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Maven and Gradle for Java project management, build automation, and dependency resolution, comparing their approaches and optimization strategies.

The article discusses creating and using custom Java libraries (JAR files) with proper versioning and dependency management, using tools like Maven and Gradle.

The article discusses implementing multi-level caching in Java using Caffeine and Guava Cache to enhance application performance. It covers setup, integration, and performance benefits, along with configuration and eviction policy management best pra

The article discusses using JPA for object-relational mapping with advanced features like caching and lazy loading. It covers setup, entity mapping, and best practices for optimizing performance while highlighting potential pitfalls.[159 characters]

Java's classloading involves loading, linking, and initializing classes using a hierarchical system with Bootstrap, Extension, and Application classloaders. The parent delegation model ensures core classes are loaded first, affecting custom class loa


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.