JShell Dollar Variable Numbering

When I enter an expression in JShell (9.0.1), it returns with:

$22 -> <value>

Where did 22 come from and what happened from 1 to 21 dollars? (They are undefined.)

I seem to vaguely remember (when I started with Java 9.0) that variables started at $ 1, which made more sense. Now, with 9.0.1, they all start at $ 22. Why?

+4
source share
1 answer

They are, just follow

/list

to find a list of all. They are, because you seem to have consumed from 1 to 21 [21 fragments / statements] until you reach the fragment $22 -> <value>.

Trying /resetand then adding a fragment should return you: -

jshell> 0+1
$1 ==> 1
+4
source

Source: https://habr.com/ru/post/1690063/


All Articles