A list of an array is created when you explicit know the size of the array and the values that would go inside the array for example
int [] iList = {5,10,15,20,25};
The first part of this array list declares the type of array list in the example it was an int, next is the brackets [] this just tells java that i want to create an array, next we give it a name i called it “iList” next is the assignment operator = with the list of numbers that i want to store in iList array, in this list array i have created five slots in the array list to store my five numbers here is an example of working with array list.
/**** Working with list *******/ int [] iList = {5,10,15,20,25}; // creates the type and size of list for (int i=0; i < iList.length; i++) // initilize the list with the for loop { //System.out.println(iList[i]); // prints out what is int he iList arary }
REMEMBER: you don't have to import an array class for you to be able to use arrays in java.
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More