logo image

JShell Hello World 

JShell Hello World 

   
   

Output:

Click on RUN button to see the output

Jshell online compiler

Write, Run & Share Jshell code online using OneCompiler's Jshell online compiler for free. It's one of the robust, feature-rich online compilers for Jshell language, running the latest Jshell version 9. Getting started with the OneCompiler's Jshell editor is easy and fast. The editor shows sample boilerplate code when you choose language as Jshell. OneCompiler also has reference programs, where you can look for the sample code and start learning. Happy learning!!

About Jshell

Jshell is Java’s first official REPL (READ-EVAL-PRINT-LOOP) tool which was introduced in JDK 9 as part of Java Enhancement Proposal. It is suitable to learn the language and also to understand unfamiliar code. With Jshell, you can test the functionality in isolation of a class.

In short, Jshell creates a simple and easy programming environment in the command line which can take input from user, read it and then prints the result.

Syntax help

Variables

When you evaluate any valid java expression, the result will be stored in the system defined variables.

You can also create your own variables

Syntax

datatype variable name = value;

Control statements

1. If-Else:

When ever you want to perform a set of operations based on a condition If-Else is used.

if(conditional-expression) {
  // code
} else {
  // code
}

Example:

int x = 3
if(x%2 == 0) {
   System.out.println("Even number");
} else {
   System.out.println("Odd number");
}

2. For:

For loop is used to iterate a set of statements based on a condition. Usually for loop is preferred when number of ierations is known in advance.

for(Initialization; Condition; Increment/decrement){  
//code  
} 

3. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations is not known in advance.

while(condition){  
 // code 
}  

4. Do-While:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {
  // code 
} while (condition); 

Help us with your feedback!

Reference Programs:

JShell

No tags available for JShell

How to use?

Choose the language in which you want to run your program, by clicking the button next to Run. And then write your code in the code box, You can use the auto complete snippets and warnings and errors which helps you to write better code faster way.
Once you are done writing your code click the Run button, now the code will be submitted to OneCompiler and you will see the results in a second.

How to contribute?

Please fork OneCompiler repository and contribute us by adding more languages or the features to the existing OneCompiler backend.
You can also contibute to the community by adding more programs which users can search and use as base code for their programs.

API & More

You can embed OneCompiler into your own website. That helps your website users to write and test their programs within your website.
If you want to run and see the results from your backend you can utilize the OneCompiler API by integrating it with your backend.