Prerequisite : JShell in Java 9
We can declare variables and use anywhere throughout Jshell session. Let’s create an
Semicolon (;) is optional, we can leave it and it works fine. See, variable b is created without using semicolon.
If we don’t provide variable name, Java create implicit variable to store the value. These variables start with $ sign. We can use these variable by specifying implicit variable, as we did in the in the following screen-shot.
We can test any valid Java expression to get instant output. See, the following example.
Adding two integers
Creating and Calling Methods
To test method business logic, create a method and get result immediately. See, the following example
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- JShell (Java 9 New Feature)
- Package Imports in JShell of Java 9
- How to create a Class in JShell of Java 9
- Are static local variables allowed in Java?
- final variables in Java
- Assigning values to static final variables in Java
- Swap two variables in one line in C/C++, Python, PHP and Java
- Scope of Variables In Java
- Variables in Java
- Final local variables in Java
- Static and non static blank final variables in Java
- Difference between static and non-static variables in Java
- Static Variables in Java with Examples
- Atomic Variables in Java with Examples
- Understanding storage of static methods and static variables in Java
- Accessing Grandparent’s member in Java using super
- Using underscore in Numeric Literals in Java
- Producer-Consumer solution using threads in Java
- Copying file using FileStreams in Java
- Swap two Strings without using third user defined variable in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.