jshell> x = 5 | Error: | cannot find symbol | symbol: variable x | x = 5 | ^ jshell> int x = 5; x ==> 5 jshell> /vars | int x = 5 jshell> double z = 4.56; z ==> 4.56 jshell> float f = 4.5 | Error: | incompatible types: possible lossy conversion from double to float | float f = 4.5; | ^-^ jshell> float f = 4.5f; f ==> 4.5 jshell> // double is a 64 bit double-precison IEEE 754 number jshell> // float is a 32 bit single-precison IEEE 754 number jshell> String s = "some string"; s ==> "some string" jshell> /vars | int x = 5 | double z = 4.56 | float f = 4.5 | String s = "some string" jshell> x += 1; $5 ==> 6 jshell> x x ==> 6 jshell> x++; //does not exist in Python $7 ==> 6 jshell> x x ==> 7 jshell> $5 $5 ==> 6 jshell> $7 $7 ==> 6 jshell> x += 2 $11 ==> 9 jshell> x *= 2 $12 ==> 18 jshell> //compound assignment is the same jshell> 6/5 $13 ==> 1 jshell> double(6)/5 | Error: | '.class' expected | double(6)/5 | ^ | Error: | unexpected type | required: value | found: class | double(6)/5 | ^----^ jshell> (double) 6/5 $14 ==> 1.2 jshell> 365%7 $15 ==> 1 jshell> // ints: + - * /(integer division) jshell> 5**3 | Error: | illegal start of expression | 5**3 | ^ jshell> Math.pow(5,3) $16 ==> 125.0 jshell> Math.cos(0) $17 ==> 1.0 jshell> int x = Math.factorial(5) | Error: | cannot find symbol | symbol: method factorial(int) | int x = Math.factorial(5); | ^------------^ jshell> Math.log(10) $18 ==> 2.302585092994046 jshell> Math.log(10,10) | Error: | method log in class java.lang.Math cannot be applied to given types; | required: double | found: int,int | reason: actual and formal argument lists differ in length | Math.log(10,10) | ^------^ jshell> Math.log10(10) $19 ==> 1.0 jshell> 4 < 5 $20 ==> true jshell> boolean b = 4 < 5; b ==> true jshell> true && true $22 ==> true jshell> //and jshell> true || true $23 ==> true jshell> // || is or jshell> 5&7 $24 ==> 5 jshell> int n = 0; n ==> 0 jshell> n = 1; n ==> 1 jshell> while(n > 0){n++;} jshell> n n ==> -2147483648 jshell> n--; $29 ==> -2147483648 jshell> n n ==> 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> short sh = 1 sh ==> 1 jshell> while(s > 0){s++;} | Error: | bad operand types for binary operator '>' | first type: java.lang.String | second type: int | while(s > 0){s++;} | ^---^ | Error: | bad operand type java.lang.String for unary operator '++' | while(s > 0){s++;} | ^-^ jshell> while(sh > 0){sh++;} jshell> sh sh ==> -32768 jshell> //byte one-byte integer jshell> b b ==> -128 jshell> b = 300; | Error: | incompatible types: possible lossy conversion from int to byte | b = 300; | ^-^ jshell> b b ==> -128 jshell> b = (byte) 300; b ==> 44 jshell> long big = 1; big ==> 1 jshell> for(int k = 0; k < 30; k++){big *= 2;} jshell> big big ==> 1073741824 jshell> for(int k = 0; k < 30; k++){big *= 2;} jshell> big big ==> 1152921504606846976 jshell> big *=2 $45 ==> 2305843009213693952 jshell> big *=2 $46 ==> 4611686018427387904 jshell> big *=2 $47 ==> -9223372036854775808 jshell> //long is a 64 bit integer. jshell> //byte, short, int, long. integer types jshell> //boolean: true, false jshell> //floatingpoint: float, double jshell> char q = 'a' q ==> 'a' jshell> (int) q $49 ==> 97 jshell> (char) 65 $50 ==> 'A' jshell>