Creating an Array of Primitives Flashcards
Give all the ways an array can be initialized !
int[] array1 = new int[] {1,2,3,4};
int[] array2 = {19,21,37,40};
int[] array3 = new int[3];
System.out.println(Arrays.toString(array1)); // [1, 2, 3, 4]
System.out.println(Arrays.toString(array2)); // [19, 21, 37, 40]
System.out.println(Arrays.toString(array3)); // [0, 0, 0]
Give a characteristic of arrays !
Arrays can contain duplicates as well as ArrayList
Define an anonymous array !
printArray(new int[]{1, 2, 3, 4, 5}); // Anonymous array
Give all the places where you can place the brackets in an array declaration !
int[] array1 = new int[] {1,2,3,4};
int array2[] = {19,21,37,40};
System.out.println(Arrays.toString(array1)); // [1, 2, 3, 4]
System.out.println(Arrays.toString(array2)); // [19, 21, 37, 40]