Friday 8 January 2021

Jshell: /vars: list the declared variables and their values

/var command is used to list the declared variables and their values.

 

Step 1: Open terminal and execute jshell command.

$jshell
|  Welcome to JShell -- Version 10.0.2
|  For an introduction type: /help intro

jshell>

Step 2: Define following variables.

String firstName = "Krishna"

int age = 10

jshell> String firstName = "Krishna"
firstName ==> "Krishna"

jshell> int age = 10
age ==> 10


Step 3: Execute the command /vars to see list of declared variables and their values.

jshell> /vars
|    String firstName = "Krishna"
|    int age = 10




 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment