Last login: Mon Oct 11 12:28:46 on ttys005 j 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. (base) MAC:Mon Oct 11:14:07:~> jshell | Welcome to JShell -- Version 15.0.1 | For an introduction type: /help intro jshell> //What is a generic class jshell> ArrayList<String> al = new ArrayList<>(); al ==> [] jshell> al.add("hello"); $2 ==> true jshell> al.add("goodbye"); $3 ==> true jshell> Integer i = 3; i ==> 3 jshell> i.getClass() $5 ==> class java.lang.Integer jshell> i++; $6 ==> 3 jshell> i i ==> 4 jshell> //autoboxing: Integer i = 3; jshell> int t = i; t ==> 4 jshell> //autounboxing jshell> new Integer(5) $9 ==> 5 jshell> //calls to new in the wrapper types are tacit. jshell> Integer.max(3,4) $10 ==> 4 jshell> Integer.max(3,4,5) | Error: | method max in class java.lang.Integer cannot be applied to given types; | required: int,int | found: int,int,int | reason: actual and formal argument lists differ in length | Integer.max(3,4,5) | ^---------^ jshell> Integer.toString(42) $11 ==> "42" jshell> Integer.parseInt("323") $12 ==> 323 jshell> Integer.parseInt("101110111", 2) $13 ==> 375 jshell> Integer.parseInt("101110111", 3) $14 ==> 7627 jshell> Integer.parseInt("101110111", 16) | Exception java.lang.NumberFormatException: For input string: "101110111" under radix 16 | at NumberFormatException.forInputString (NumberFormatException.java:68) | at Integer.parseInt (Integer.java:652) | at (#15:1) jshell> Integer.parseInt("10111", 16) $16 ==> 65809 jshell> new ArrayList<String>() $17 ==> [] jshell> StringBuffer sb = new StringBuffer(); sb ==> jshell> sb.append("cows") $19 ==> cows jshell> sb.append("horses") $20 ==> cowshorses jshell> sb.append(42) $21 ==> cowshorses42 jshell> sb.toString() $22 ==> "cowshorses42" jshell> //how do I clear a string buffer? jshell> sb.delete(0, sb.length()) $23 ==> jshell> sb sb ==> jshell> for(char k = 'a'; k <= 'z'; k++){sb.append(k);} jshell> sb sb ==> abcdefghijklmnopqrstuvwxyz jshell>