Java 9 : JShell example

In your command prompt, type jshell and press enter.
You will see a message and then a jshell> prompt:


Use Ctrl + A to reach the beginning of the line and Ctrl + E to reach the end of the line.

1)
/help intro
or
/help
help you in interacting with JShell

2)
/imports java.lang.Object
This imports the Object class

3)
Let's declare an Employee class.
class Employee{
private String empId;
public String getEmpId() {
return empId;
}
public void setEmpId ( String empId ) {
this.empId = empId;
}
}

4)
/open 
loading the code from within a file.
/open Test.java
It will load the Test class definition and create an Test object.


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation