Last login: Thu Apr 7 11:02:40 on ttys015 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:Thu Apr 07:12:44:~> jshell | Welcome to JShell -- Version 17.0.1 | For an introduction type: /help intro jshell> Integer i = 5; i ==> 5 jshell> Double d = 4.5; d ==> 4.5 jshell> i.getClass() $3 ==> class java.lang.Integer jshell> d.getClass() $4 ==> class java.lang.Double jshell> int k = 5; k ==> 5 jshell> k.getClass() | Error: | int cannot be dereferenced | k.getClass() | ^--------^ jshell> i = new Integer(5); | Warning: | Integer(int) in java.lang.Integer has been deprecated and marked for removal | i = new Integer(5); | ^------------^ i ==> 5 jshell> Integer f = 42; f ==> 42 jshell> f.getClass() $8 ==> class java.lang.Integer jshell> int y = f; y ==> 42 jshell> Integer.BYTES $10 ==> 4 jshell> Integer.SIZE $11 ==> 32 jshell> Double.BYTES $12 ==> 8 jshell> Double.SIZE $13 ==> 64 jshell> Integer.MAX_VALUE $14 ==> 2147483647 jshell> Integer.MIN_VALUE $15 ==> -2147483648 jshell> Short.MAX_VALUE $16 ==> 32767 jshell> String s= "4333"; s ==> "4333" jshell> int n = Integer.parseInt(s); n ==> 4333 jshell> Integer.parseInt("cow") | Exception java.lang.NumberFormatException: For input string: "cow" | at NumberFormatException.forInputString (NumberFormatException.java:67) | at Integer.parseInt (Integer.java:668) | at Integer.parseInt (Integer.java:786) | at (#19:1) jshell> ArrayList nums = ArrayList<>(); | Error: | illegal start of expression | ArrayList nums = ArrayList<>(); | ^ | Error: | -> expected | ArrayList nums = ArrayList<>(); | ^ jshell> ArrayList nums = new ArrayList<>(); | Error: | unexpected type | required: reference | found: int | ArrayList nums = new ArrayList<>(); | ^-^ jshell> ArrayList nums = new ArrayList<>(); nums ==> [] jshell> nums.add(42); $21 ==> true jshell> nums.add(33); $22 ==> true jshell> nums.add(21); $23 ==> true jshell> nums.add(122); $24 ==> true jshell> nums nums ==> [42, 33, 21, 122] jshell> TreeSet ts = new TreeSet<>(); ts ==> [] jshell> ts.add(4) $27 ==> true jshell> ts.add(4) $28 ==> false jshell> ts ts ==> [4] jshell> ts.add(5) $30 ==> true jshell> ts.add(6) $31 ==> true jshell> ts ts ==> [4, 5, 6] jshell> ts.add(-1) $33 ==> true jshell> ts ts ==> [-1, 4, 5, 6] jshell> HashSet hs = new HashSet<>(); hs ==> [] jshell> hs.add("hello"); $36 ==> true jshell> hs.add("goodbye"); $37 ==> true jshell> hs.add("zygote") $38 ==> true jshell> hs hs ==> [zygote, goodbye, hello] jshell> Double.parseDouble("4.55654"); $40 ==> 4.55654 jshell> /// Type.parseType(string) -> type jshell> Boolean.parseBoolean("false") $41 ==> false jshell> Long.parseLong("234532535") $42 ==> 234532535 jshell> Byte.parseByte("12") $43 ==> 12 jshell> Integer.parseInt("1111101111", 2) $44 ==> 1007 jshell> Integer.parseInt("1111101112", 2) | Exception java.lang.NumberFormatException: For input string: "1111101112" under radix 2 | at NumberFormatException.forInputString (NumberFormatException.java:67) | at Integer.parseInt (Integer.java:668) | at (#45:1) jshell> Integer.parseInt("syzygy", 36) $46 ==> 1751837506 jshell> Integer.parseInt("syzygy", 37) | Exception java.lang.NumberFormatException: radix 37 greater than Character.MAX_RADIX | at Integer.parseInt (Integer.java:639) | at (#47:1) jshell> Integer.parseInt("abcdef", 16) $48 ==> 11259375 jshell> 0xFF $49 ==> 255 jshell> 0b10111101 $50 ==> 189 jshell> 0o55 | Error: | ';' expected | 0o55 | ^ jshell> 055 $51 ==> 45 jshell> 09 | Error: | ';' expected | 09 | ^ jshell> 099999 | Error: | ';' expected | 099999 | ^ jshell> 099999; | Error: | ';' expected | 099999; | ^ jshell> Integer.signum(40) $52 ==> 1 jshell> Integer.signum(2) $53 ==> 1 jshell> Integer.signum(3) $54 ==> 1 jshell> Integer.signum(0) $55 ==> 0 jshell> Integer.signum(9) $56 ==> 1 jshell> Integer.signum(-9) $57 ==> -1 jshell> Integer.signum(-1) $58 ==> -1 jshell> Integer.signum(11) $59 ==> 1 jshell> Integer.toString(23442) $60 ==> "23442" jshell> "" + 23442 $61 ==> "23442" jshell> Integer.toString(100, 16) $62 ==> "64" jshell> Integer.toString(101, 16) $63 ==> "65" jshell> Integer.toString(110, 16) $64 ==> "6e" jshell> Integer.toString(111, 16) $65 ==> "6f" jshell> Integer.toString(112, 16) $66 ==> "70" jshell> double d = 1.0/0 d ==> Infinity jshell> Double.isFinite(d) $68 ==> false jshell> Double.isNaN(d) $69 ==> false jshell> Character.BYTES $70 ==> 2 jshell> Character.isAlphabetic(' | Error: | unclosed character literal | Character.isAlphabetic(' | ^ jshell> Character.isAlphabetic('a') $71 ==> true jshell> Character.isAlphabetic('@') $72 ==> false jshell> Character.isDigit('3') $73 ==> true jshell> Character.isDigit('a') $74 ==> false jshell> Character.isDigit('9') $75 ==> true jshell> Character.isISOControl('\n') $76 ==> true jshell> Character.isISOControl('a') $77 ==> false jshell> Character.isISOControl('\r') $78 ==> true jshell> Character.isWhitespace(' ') $79 ==> true jshell> Character ch = 'a'; ch ==> 'a' jshell> char dh = ch; dh ==> 'a' jshell> "cat".compareToIgnoreCase("n") < 0