 
  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
Using Variables in JShell of Java 9
In JShell 9, variables can be declared during a session. Once the user has logged into the session, they can declare a variable as follows −
jshell> int val = 56 ;
Italics indicate the terminal, once the user has logged in to their session.
The above line would print the below output. The semicolon in the above line is optional, and it will run fine without the semicolon also.
Output
val = = > 56
When an integer value is defined by assigning it to a variable name on the JShell, and it is executed, by pressing ‘Enter’ key, it is displayed on the next line of JShell command line.
Incase we don’t assign a variable to a value and just print it on the JShell, it will assign a variable to the value −
jshell> 79
Output
$3 = = > 79
When an integer value is defined without assigning it to a variable name on the JShell, and it is executed, by pressing ‘Enter’ key, it is displayed on the next line of JShell command line. Here, JShell itself assigns a variable name to the most recently entered variable value.
