Last login: Wed Mar 23 13:16:00 on ttys002 The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`. For more details, please visit https://support.apple.com/kb/HT208050. MAC:Wed Mar 23:14:09:~> jshell | Welcome to JShell -- Version 17.0.1 | For an introduction type: /help intro jshell> int x = 4; x ==> 4 jshell> int p = 1; p ==> 1 jshell> p *= 1048576; $3 ==> 1048576 jshell> p p ==> 1048576 jshell> p *= 1048576; $5 ==> 0 jshell> p p ==> 0 jshell> int biggie = Integer.MAX_VALUE; biggie ==> 2147483647 jshell> biggie + 1 $8 ==> -2147483648 jshell> biggie biggie ==> 2147483647 jshell> biggie += 1 $10 ==> -2147483648 jshell> biggie biggie ==> -2147483648 jshell> //32 bit signed integer in two's complement notation jshell> byte b = 0; b ==> 0 jshell> while(b >= 0){ b++;} jshell> b b ==> -128 jshell> //byte is an 8-bit integer jshell> short s = 0; s ==> 0 jshell> while(s >= 0){s++;} jshell> s s ==> -32768 jshell> Short.MAX_VALUE $18 ==> 32767 jshell> Short.MIN_VALUE $19 ==> -32768 jshell> Long.MAX_VALUE $20 ==> 9223372036854775807 jshell> Long.MIN_VALUE $21 ==> -9223372036854775808 jshell> $21 $21 ==> -9223372036854775808 jshell> $21 + 1 $23 ==> -9223372036854775807 jshell> $21 - 1 $24 ==> 9223372036854775807 jshell> String s = "hello"; s ==> "hello" jshell> char bugs = 'z'; bugs ==> 'z' jshell> bugs--; $27 ==> 'z' jshell> bugs bugs ==> 'y' jshell> bugs -= 32; $29 ==> 'Y' jshell> bugs bugs ==> 'Y' jshell> (int) bugs $31 ==> 89 jshell> (char) 97 $32 ==> 'a' jshell> (char) 945 $33 ==> 'α' jshell> (char) 946 $34 ==> 'β' jshell> (char) 947 $35 ==> 'γ' jshell> (char) 948 $36 ==> 'δ' jshell> (char) 10000 $37 ==> '✐' jshell> (char) 5688 $38 ==> 'ᘸ' jshell> (char) 3345 $39 ==> '഑' jshell> (char) 25 $40 ==> '\031' jshell> (char) 122 $41 ==> 'z' jshell> boolean foo = 4*4 == 16 foo ==> true jshell> foo foo ==> true jshell> not true | Error: | ';' expected | not true | ^ | Error: | cannot find symbol | symbol: variable not | not true | ^-^ jshell> !foo $44 ==> false jshell> !true $45 ==> false jshell> !false $46 ==> true jshell> true and true | Error: | ';' expected | true and true | ^ | Error: | not a statement | true and true | ^-^ | Error: | ';' expected | true and true | ^ jshell> true && true $47 ==> true jshell> true && false $48 ==> false jshell> false && true $49 ==> false jshell> false && false $50 ==> false jshell> true || true $51 ==> true jshell> true || false $52 ==> true jshell> false || true $53 ==> true jshell> false || false $54 ==> false jshell> true ^ true $55 ==> false jshell> true ^ false $56 ==> true jshell> false ^ true $57 ==> true jshell> false ^ false $58 ==> false jshell> true + true | Error: | bad operand types for binary operator '+' | first type: boolean | second type: boolean | true + true | ^---------^ jshell> double z = 5; z ==> 5.0 jshell> z z ==> 5.0 jshell> // double is just like Python's float jshell> //float is a 32 bit floating point number jshell> Float.MAX_VALUE $61 ==> 3.4028235E38 jshell> Double.MAX_VALUE $62 ==> 1.7976931348623157E308 jshell> .1 + .1 + .1 == .3 $63 ==> false jshell> .1 + .1 + .1 $64 ==> 0.30000000000000004 jshell> jshell> /vars | int x = 4 | int p = 0 | int $3 = 1048576 | int $5 = 0 | int biggie = -2147483648 | int $8 = -2147483648 | int $10 = -2147483648 | byte b = -128 | short $18 = 32767 | short $19 = -32768 | long $20 = 9223372036854775807 | long $21 = -9223372036854775808 | long $23 = -9223372036854775807 | long $24 = 9223372036854775807 | String s = "hello" | char bugs = 'Y' | char $27 = 'z' | char $29 = 'Y' | int $31 = 89 | char $32 = 'a' | char $33 = 'α' | char $34 = 'β' | char $35 = 'γ' | char $36 = 'δ' | char $37 = '✐' | char $38 = 'ᘸ' | char $39 = '഑' | char $40 = '\031' | char $41 = 'z' | boolean foo = true | boolean $44 = false | boolean $45 = false | boolean $46 = true | boolean $47 = true | boolean $48 = false | boolean $49 = false | boolean $50 = false | boolean $51 = true | boolean $52 = true | boolean $53 = true | boolean $54 = false | boolean $55 = false | boolean $56 = true | boolean $57 = true | boolean $58 = false | double z = 5.0 | float $61 = 3.4028235E38 | double $62 = 1.7976931348623157E308 | boolean $63 = false | double $64 = 0.30000000000000004 jshell> /save junk jshell> String example = "test"; example ==> "test" jshell> example.toUpperCase() $66 ==> "TEST" jshell> z.round() | Error: | double cannot be dereferenced | z.round() | ^-----^ jshell>