
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
What are the different feedback modes in JShell in Java 9?
When performing an operation in the JShell tool, it displays a message in return (success of the command, error, and type of a variable created as well as its value). It has been customized using the command: "/set feedback". This command displays the type of return currently configured as well as the different return modes available.
jshell> /set feedback | /set feedback normal | | Available feedback modes: | concise | normal | silent | verbose
There are four feedback modes available in JShell as listed below:
1) /set feedback normal: This is the default JShell feedback. When we evaluate an expression, JShell returns the corresponding result and an internal variable in which the value was stored. In the case of variable creation, JShell returns the name of the variable and the corresponding value. When creating a data type (method or class), JShell sends a return specifying the type we have created.
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)
2) /set feedback verbose: This the most informative feedback mode. When evaluating an instruction, it displays the corresponding result as well as an internal variable in which it has been assigned, and the type of the expression. It will be the same for the creation of a variable. Regarding the creation of a data type, the return is identical to normal mode.
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)
3) /set feedback concise: This mode displays the minimum amount of information. When evaluating an expression, it tells us the name of an internal variable created as well as the result of the expression. On the other hand, regarding the creation of a data type (variable, method, or class), no return is made from JShell (unless the code is in error).
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"; | ^---^
4) /set feedback silent: This mode doesn't display any information. When we enter an expression to evaluate, JShell stores the result in an internal variable but doesn't indicate the corresponding result on the screen. The same can be true for the creation of a data type (variable, method, or class). Everything has been done internally without displaying any result on the screen (except in the event of order in error).
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"; | ^---^ ->
- Related Articles
- What are the different shortcut keys in JShell in Java 9?
- What are the different "/edit" commands in JShell in Java 9?
- What are the different startup scripts in JShell in Java 9?
- What are the different "/types" commands in JShell in Java 9?
- What are the different "/vars" commands in JShell in Java 9?
- What are the different compilation modes of a module in Java 9?
- What are the useful commands in JShell in Java 9?
- What are the rules for external declarations in JShell in Java 9?
- JShell in Java 9?
- How to display different list commands in JShell in Java 9?
- What are the rules we need to follow in JShell in Java 9?
- What are the different modes of nutrition?
- What are the different module types in Java 9?
- What is a forward reference in JShell in Java 9?
- What is the use of the Tab key in JShell in Java 9?
