Interview Questions, Answers and Tutorials

Category: Arrays

08 Arrays

8.1 | Arrays An array is a data structure that stores a collection of values of the same data type. Values stored in the array are accessible through the array index //Declaring an array of integers int arr1[];   //Creating an integer array with values int[] arr0 = {2,3,4,5,6,7};   //Creating an integer array which can hold 100 integers int arr2[] = new int[100]; //Or, int arraySize = 100; int arr3[] = new int[arraySize]; //Assigning values to the array arr3[0] = 1; arr3[1] = 2; //Creating a string array which can hold 100 values String arr4[] = new String[100];  …