Java Language Expressions


Example

Within JShell, you can evaluate Java expressions, with or without semicolons. These can range from basic expressions and statements to more complex ones:

jshell> 4+2
jshell> System.out.printf("I am %d years old.\n", 421)

Loops and conditionals are fine, too:

jshell> for (int i = 0; i<3; i++) {
   ...> System.out.println(i);
   ...> }

It is important to note that expressions within blocks must have semicolons!