- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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
85 Lectures 6 hours
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.
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 −
$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.
- How to create scratch variables in JShell in Java 9?
- JShell in Java 9?
- Package Imports in JShell of Java 9
- How to define expressions, variables, and methods in JShell in Java 9?
- How to implement java.time.LocalDate using JShell in Java 9?
- How to implement JShell using JavaFX in Java 9?
- How to implement an ArrayList using JShell in Java 9?
- How to debug JShell in Java 9?
- How JShell tool works internally in Java 9?
- How to get JShell documentation in Java 9?
- How to modify the default editor of JShell in Java 9?
- How can we customize the start of JShell in Java 9?
- How to create JShell instance programmatically in Java 9?
- How to reset the JShell session in Java 9?
- How to print the pattern of stars in JShell in Java 9?