 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to re-execute existing snippets in JShell in Java 9?\\n
JShell is the first REPL tool introduced in Java 9. We can able to execute simple snippets in a command-line prompt by using JShell tool. We can start a JShell session by typing "jshell" command, stop the session by typing "/exit" command, and search for particular command by using "/help" command.
The "/reload" command can be used to re-execute all existing snippets in JShell. We can also remove all prior code from a JShell session by using the "/reset" command.
In the below code snippet, we have created a set of snippets.
jshell> 2+10 $1 ==> 12 jshell> String s = "Tutorialspoint" s ==> "Tutorialspoint" jshell> System.out.println("Tutorialspoint") Tutorialspoint jshell> int num1 = 25 num1 ==> 25 jshell> /1 2+10 $5 ==> 12 jshell> /2 String s = "Tutorialspoint"; s ==> "Tutorialspoint" jshell> /3 System.out.println("Tutorialspoint") Tutorialspoint jshell> /4 int num1 = 25; num1 ==> 25 In the below code snippet, we can apply the "/reload" command. Jshell tool re-executes all existing snippets and prints it.
jshell> /reload | Restarting and restoring state. -: 2+10 -: String s = "Tutorialspoint"; -: System.out.println("Tutorialspoint") Tutorialspoint -: int num1 = 25; -: 2+10 -: String s = "Tutorialspoint"; -: System.out.println("Tutorialspoint") Tutorialspoint -: int num1 = 25; -: int num1 = 25; In the below code snippet, we can apply the "/reset" command to remove all prior code from a JShell session and prints "Resetting State".
jshell> /reset | Resetting state. jshell>
