(base) MAC:Mon Oct 12:09:57:~> jshell | Welcome to JShell -- Version 14.0.1 | For an introduction type: /help intro jshell> int x = 5; x ==> 5 jshell> x = "cowabunga" | Error: | incompatible types: java.lang.String cannot be converted to int | x = "cowabunga" | ^---------^ jshell> x += 4; $2 ==> 9 jshell> //compound assignment and assignment: just like Py jshell> //once a variable has a type, it cannot be changed. jshell> 4*5 $3 ==> 20 jshell> 4 + 5 $4 ==> 9 jshell> 4 - 5 $5 ==> -1 jshell> 4/5 $6 ==> 0 jshell> 4%5 $7 ==> 4 jshell> 4**5 | Error: | illegal start of expression | 4**5 | ^ jshell> // you got POW for using pow. jshell> Math.pow(4,5) $8 ==> 1024.0 jshell> pow(4,5) | Error: | cannot find symbol | symbol: method pow(int,int) | pow(4,5) | ^-^ jshell> byte b = 6; b ==> 6 jshell> while(b > 0){ b++;} jshell> b b ==> -128 jshell> b--; $12 ==> -128 jshell> b b ==> 127 jshell> short s = 0; s ==> 0 jshell> s s ==> 0 jshell> while(s >= 0){s++;} jshell> s s ==> -32768 jshell> s--; $19 ==> -32768 jshell> s s ==> 32767 jshell> int i = 0; i ==> 0 jshell> while(i >= 0){i++;} jshell> i i ==> -2147483648 jshell> i--; $24 ==> -2147483648 jshell> i i ==> 2147483647 jshell> long i = 0; i ==> 0 jshell> Long.MAX_VALUE $27 ==> 9223372036854775807 jshell> Long.MIN_VALUE $28 ==> -9223372036854775808 jshell> Math.PI $29 ==> 3.141592653589793 jshell> double x = 5.6; x ==> 5.6 jshell> (int) x $31 ==> 5 jshell> (double) 4 $32 ==> 4.0 jshell> (boolean) 5 | Error: | incompatible types: int cannot be converted to boolean | (boolean) 5 | ^ jshell> true $33 ==> true jshell> false $34 ==> false jshell> 4 < 5 $35 ==> true jshell> // < <= >= > == != jshell> // These are the relational operators. jshell> char c = 'a | Error: | unclosed character literal | char c = 'a | ^ jshell> char c = 'a' c ==> 'a' jshell> (int) c $37 ==> 97 jshell> (char) 945 $38 ==> 'α' jshell> String foo = "bar"; foo ==> "bar" jshell> /exit | Goodbye (base) MAC:Mon Oct 12:10:17:~>