Getting Started with JShell:
Q1. How to Start and Stop JShell?
Open the Jshell from the command prompt in verbose mode. Using this command jshell -v Or jshell.
We will discuss further the difference b/w jshell and jshell -v command.
Refer the below Image:
Q2.How to exit JShell?
Just type this command /exit.
Refer the below Image:
Now its time to discuss the difference b/w with -v and without -v.
-v stands for verbose mode. It means in verbose mode we will get the extra information from the Jshell.
Let's see the example in verbose mode and non-verbose mode.
- Without -v
- With -v
Note: If any information displaying on the jshell starts with '|' pipe symbol, it is the information to the programmer from the jshell.
EX:
Refer the below example:
jshell> System.out.println("Hello World")
Hello World
In the above example, we observe that the output does not start with '|' pipe symbol because it is not information from the Jshell.
Note: Terminating semicolons are automatically added at the end of complete snippet by JShell if not entered.
EmoticonEmoticon