
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
What is the importance of REPL in Java 9?
REPL stands for Read-Eval-Print-Loop. It is a shell where the user types an expression, it's evaluated, and the result returned to the user. The main purpose of using REPL is to interact quickly with Java programs without creating a java file, compile it, and run it. JShell is very useful for the developers and allows us to learn the Java language.
Below are some of the features of REPL
- It’s built-in in Java 9.
- We can test any Java expression without a class file, compiling and running it.
- It autocompletes the methods, just typing the TAB key, as in your editor.
- We can define methods, and call them later.
- It shows us the exceptions if they are thrown.
- We can edit any method, and change them.
- There are built-in commands.
Below are the few examples of REPL using the Jshell tool.
Example-1
C:\Users\User>jshell | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro jshell> Math.round(34.543) $1 ==> 35
Example-2
jshell> void test(String s) { ...> System.out.println(s); ...> } | created method test(String) jshell> test("TutorialsPoint") TutorialsPoint
- Related Articles
- What are the different status states of REPL in Java 9?
- What is the importance of jmod format in Java 9?
- What is the importance of jdeps tool in Java 9?
- What is the importance of the ProcessHandle interface in Java 9?
- What is the importance of the jcmd tool in Java 9?
- Importance of the Collectors.filtering() method in Java 9?
- Importance of Collectors.flatMapping() method in Java 9?
- Importance of ofInstant() method in Java 9?
- Importance of Thread.onSpinWait() method in Java 9?
- Importance of MethodHandles class in Java 9?
- Importance of Optional.or() method in Java 9?
- Importance of destroyForcibly() method in Java 9?
- What is the importance of "Java.lang.Class" in Java?
- What is the importance of OverlayLayout in Java?
- Importance of transferTo() method of InputStream in Java 9?

Advertisements