You can declare local variables within JShell:

jshell> String s = "hi"
jshell> int i = s.length

Keep in mind that variables can be redeclared with different types; this is perfectly valid in JShell:

jshell> String var = "hi"
jshell> int var = 3

To see a list of variables, enter /vars at the JShell prompt.