What is JShell?
JShell is a new tool introduced with Java 9. It is an interactive read-eval-print loop tool that is used to evaluate the following Java programming language components--declarations, statements, and expressions. It has its own API so that it can be used by external applications.
Note
Read-Eval-Print Loop is often referred to as REPL, taking the first letter from each word in the phrase. It is also knows language shell or interactive top-level.
The introduction of JShell was a result of Java Enhancement Program (JEP) 222. Here are the stated goals of this JEP in regards to the Java Shell command-line tool:
- Facilitate rapid investigation
- Facilitate rapid coding
- Provide an edit history
The rapid investigation and coding listed previously includes statements and expressions. Impressively, these statements and expressions do not need to be part of a method. Furthermore, variables and methods are not required to be part of a class, making this tool especially dynamic.
In addition, the...