(base) MAC:Mon Apr 12:14:10:HP> jshell | Welcome to JShell -- Version 15.0.1 | For an introduction type: /help intro jshell> x = 5 | Error: | cannot find symbol | symbol: variable x | x = 5 | ^ jshell> int x = 5; x ==> 5 jshell> // variables AND objects have type jshell> x = "cowpies" | Error: | incompatible types: java.lang.String cannot be converted to int | x = "cowpies" | ^-------^ jshell> x = 1; x ==> 1 jshell> x x ==> 1 jshell> /vars | int x = 1 jshell> while(x > 0){ x = x + 1;} jshell> x x ==> -2147483648 jshell> x = x - 1 x ==> 2147483647 jshell> x x ==> 2147483647 jshell> // int is a 32 bit signed integer in two's complement notation jshell> byte b = 1; b ==> 1 jshell> while(b > 0){b++;} jshell> b b ==> -128 jshell> //bytes are between -128 and 127 jshell> short s = 1 s ==> 1 jshell> while(s > 0){s++;} jshell> s s ==> -32768 jshell> //a short is a 16 bit signed integer ...> jshell> long ell = 1; ell ==> 1 jshell> for(int k = 0; k < 30; k++){ell *= 2;} jshell> ell ell ==> 1073741824 jshell> for(int k = 0; k < 30; k++){ell *= 2;} jshell> ell ell ==> 1152921504606846976 jshell> ell *= 2 $19 ==> 2305843009213693952 jshell> ell *= 2 $20 ==> 4611686018427387904 jshell> ell *= 2 $21 ==> -9223372036854775808 jshell> //four integer types byte(8), short(16), int(32), long(64) jshell> String s = "fooment"; s ==> "fooment" jshell> s s ==> "fooment" jshell> 4 < 5 $24 ==> true jshell> 4 > 5 $25 ==> false jshell> //boolean constants: true, false jshell> (boolean) 1 | Error: | incompatible types: int cannot be converted to boolean | (boolean) 1 | ^ jshell> double z = 4.22422 z ==> 4.22422 jshell> //64 bit floating point number (IEEE 754 standard) jshell> float boat = 5.2f; boat ==> 5.2 jshell> //32 bit floating point number (IEEE 754 standard) jshell> 4 + 5 $28 ==> 9 jshell> 4 + .3 $29 ==> 4.3 jshell> char x = 'a'; x ==> 'a' jshell> //char literals are bounded by single quotes! jshell> (int) x $31 ==> 97 jshell> (char) 945 $32 ==> 'α' jshell> (char) 946 $33 ==> 'β' jshell> (char) 947 $34 ==> 'γ' jshell> (char)5000 $35 ==> 'ᎈ' jshell> (char)5545 $36 ==> 'ᖩ' jshell> (char)2000 $37 ==> 'ߐ' jshell> (char)2001 $38 ==> 'ߑ' jshell> (char)2002 $39 ==> 'ߒ' jshell> (char)2003 $40 ==> 'ߓ' jshell> (char)2004 $41 ==> 'ߔ' jshell> //eight primitive types jshell> //byte, int, short, long jshell> //float double jshell> //char boolean jshell> /vars | byte b = -128 | long ell = -9223372036854775808 | long $19 = 2305843009213693952 | long $20 = 4611686018427387904 | long $21 = -9223372036854775808 | String s = "fooment" | boolean $24 = true | boolean $25 = false | double z = 4.22422 | float boat = 5.2 | int $28 = 9 | double $29 = 4.3 | char x = 'a' | int $31 = 97 | char $32 = 'α' | char $33 = 'β' | char $34 = 'γ' | char $35 = 'ᎈ' | char $36 = 'ᖩ' | char $37 = 'ߐ' | char $38 = 'ߑ' | char $39 = 'ߒ' | char $40 = 'ߓ' | char $41 = 'ߔ' jshell> $35 $35 ==> 'ᎈ' jshell> s.toUpperCase() $43 ==> "FOOMENT" jshell> s[0] | Error: | array required, but java.lang.String found | s[0] | ^--^ jshell> s.charAt(0) $44 ==> 'f' jshell> s.charAt(1) $45 ==> 'o' jshell>