All you have to do is:
CopymyList.get(Index);
This would return you the type of Object you used while creating the ArrayList. In your case it will return a String. Hence, what you can do is:
CopyString firstElement = myList.get(0); //This would return "Hello"
This also shows that ArrayList indices start with 0
java - How would use a get() method to access an element in an arrayList? - Stack Overflow
java - Get specific ArrayList item - Stack Overflow
How do I get the number of items in ArrayList
Getting Values in an ArrayList in Java
Videos
All you have to do is:
CopymyList.get(Index);
This would return you the type of Object you used while creating the ArrayList. In your case it will return a String. Hence, what you can do is:
CopyString firstElement = myList.get(0); //This would return "Hello"
This also shows that ArrayList indices start with 0
CopyString a = myList.get(0); //a = "hello"
String b = myList.get(1); //b = "5"
As many have already told you:
mainList.get(3);
Be sure to check the ArrayList Javadoc.
Also, be careful with the arrays indices: in Java, the first element is at index 0. So if you are trying to get the third element, your solution would be mainList.get(2);
Time to familiarize yourself with the ArrayList API and more:
ArrayList at Java 6 API Documentation
For your immediate question:
mainList.get(3);
Hello! I can't seem to get the elements I've inputted inside my LIST, this function keeps on returning "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0" , help I've been searching for days, please ask if you need to see other parts of my code PS. the variable z is static and has a value of 0 thank u in advance for helping
static String[][] listToArray(ArrayList<String> LIST){
int size = LIST.size();
String [][] array = new String[z][size];
for(int j = 0; j < LIST.size(); j++){
array[z][j] = LIST.get(j);
}
return array;
}