Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, an array of elements can be made in Android. An array is a collection of similar data types that are stored in contiguous memory locations. In Android, arrays can be created for various data types such as integers, strings, characters, etc.

Here is an example of creating an array of integers in Android:

int[] myArray = new int[5]; // creating an array of 5 integers myArray[0] = 10; // assigning value 10 to the first element of the array myArray[1] = 20; // assigning value 20 to the second element of the array myArray[2] = 30; // assigning value 30 to the third element of the array myArray[3] = 40; // assigning value 40 to the fourth element of the array myArray[4] = 50; // assigning value 50 to the fifth element of the array

// Accessing elements of the array int firstElement = myArray[0]; // will return 10 int secondElement = myArray[1]; // will return 20 int thirdElement = myArray[2]; // will return 30 int fourthElement = myArray[3]; // will return 40 int fifthElement = myArray[4]; // will return 50