Last login: Tue Sep 8 11:18:55 on ttys004 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:Tue Sep 08:11:28:listGames> jshell | Welcome to JShell -- Version 14.0.1 | For an introduction type: /help intro jshell> int[] x = new int[10]; x ==> int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } jshell> String[] names = new String[]{"Manny", "Moe", "Jack"} names ==> String[3] { "Manny", "Moe", "Jack" } jshell> for(int k = 0; k < x.length; k++){x[k] = k*k;} jshell> x x ==> int[10] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 } jshell> x[0:] | Error: | ']' expected | x[0:] | ^ jshell> Arrays.copyOfRange(x, 1) | Error: | no suitable method found for copyOfRange(int[],int) | method java.util.Arrays.<T>copyOfRange(T[],int,int) is not applicable | (cannot infer type-variable(s) T | (actual and formal argument lists differ in length)) | method java.util.Arrays.<T,U>copyOfRange(U[],int,int,java.lang.Class<? extends T[]>) is not applicable | (cannot infer type-variable(s) T,U | (actual and formal argument lists differ in length)) | Arrays.copyOfRange(x, 1) | ^----------------^ jshell> Arrays.copyOfRange(x, 1, 10) $5 ==> int[9] { 1, 4, 9, 16, 25, 36, 49, 64, 81 } jshell> Arrays.copyOfRange(x, 3,5) $6 ==> int[2] { 9, 16 } jshell> x x ==> int[10] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 } jshell> int[] y = Arrays.copyOf(x, 20); y ==> int[20] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } jshell> ArrayList<Integer> al = al.addAll(y); | Error: | incompatible types: int[] cannot be converted to java.util.Collection<? extends java.lang.Integer> | ArrayList<Integer> al = al.addAll(y); | ^ jshell> ArrayList<Integer> al = al.addAll(y.asList()); | Error: | cannot find symbol | symbol: method asList() | ArrayList<Integer> al = al.addAll(y.asList()); | ^------^ jshell> ArrayList<Integer> al = al.addAll(asList(y)); | Error: | cannot find symbol | symbol: method asList(int[]) | ArrayList<Integer> al = al.addAll(asList(y)); | ^----^ jshell> ArrayList<Integer> al = al.addAll(Arrays.asList(y)); | Error: | incompatible types: inference variable T has incompatible bounds | lower bounds: java.lang.Integer,java.lang.Object | lower bounds: int[] | ArrayList<Integer> al = al.addAll(Arrays.asList(y)); | ^-------^ jshell> y y ==> int[20] { 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } jshell> ArrayList<String> al = new ArrayList<>(); al ==> [] jshell> s | Error: | cannot find symbol | symbol: variable s | s | ^ jshell> al.addAll(names); | Error: | incompatible types: java.lang.String[] cannot be converted to java.util.Collection<? extends java.lang.String> | al.addAll(names); | ^---^ jshell> al.addAll(Arrays.asList(names)); $11 ==> true jshell> al al ==> [Manny, Moe, Jack] jshell> #this only works for object types, not primitives | Error: | illegal character: '#' | #this only works for object types, not primitives | ^ | Error: | ';' expected | #this only works for object types, not primitives | ^ jshell>