JShell is an interactive tool to evaluate the program declarations, expressions, and statements in a read-eval-print loop (REPL). REPL means to evaluate the code and get an output of each element instantly.
Advantages of JShell :
By writing a java program using JShell, you can evaluate each element one at a time and get the output immediately.
- Easy to write and understand the concepts.
- JShell is able to get the output of Each element immediately.
- Easy to debug and fix errors.
- Easy to manage your code.
- JShell can help to test each statement individually.
- JShell doesn’t replace the IDE, user can easily run IDE code in JShell and vice-versa.
Table of Contents
What if we don’t use JShell? We need the following steps to execute the Java Program.
- Need to write a complete java program.
- Compile and fix each and every error if occur.
- Compile and Run the Java Program.
- If getting any issues then need to fix.
- Edit and re-compile the code.
- Repeat the process until you will get the output.
If you are using JShell Java Tool then you don’t need to follow the above steps.
Let’s have a quick look at the JShell Tool example, the following java program will print the “Hello, JShell !”.
C:\Users\codenaive>jshell | Welcome to JShell -- Version 16.0.1 | For an introduction type: /help intro jshell> System.out.print("Hello, JShell !"); Hello, JShell ! jshell>