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

Answer from noMAD on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › ArrayList.html
ArrayList (Java Platform SE 8 )
October 20, 2025 - The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation. Each ArrayList ...
🌐
W3Schools
w3schools.com › java › ref_arraylist_get.asp
Java ArrayList get() Method
import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> cars = new ArrayList<String>(); cars.add("Volvo"); cars.add("BMW"); cars.add("Ford"); cars.add("Mazda"); System.out.println(cars.get(0)); } }
Discussions

java - How would use a get() method to access an element in an arrayList? - Stack Overflow
This is my code I have so far but I don't know how to access an element in the Array myList? And is the inex of an array list start at 0 or 1? I have just found out about array lists and i need a ... More on stackoverflow.com
🌐 stackoverflow.com
java - Get specific ArrayList item - Stack Overflow
public static ArrayList mainList = someList; How can I get a specific item from this ArrayList? mainList[3]? More on stackoverflow.com
🌐 stackoverflow.com
How do I get the number of items in ArrayList
Getting the count of elements in an ArrayList seems to be more difficult that I would have expected 😀 I have seen code in the wild using .count() and len() but from this issue Add a method to return length of ArrayList · Issue #5669 · ziglang/zig · GitHub it seems those have been deprecated ... More on ziggit.dev
🌐 ziggit.dev
1
0
June 16, 2024
Getting Values in an ArrayList in Java
You're creating an array with length z, which is zero. In order to have an element at index zero, the length must be >= 1. More on reddit.com
🌐 r/javahelp
4
8
December 11, 2022
🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-get-method-java-examples
ArrayList get(index) Method in Java with Examples - GeeksforGeeks
December 10, 2024 - // Java program to demonstrate the working of // get() method in ArrayList import java.util.ArrayList; public class GFG { public static void main(String[] args) { // Creating an ArrayList of Integers ArrayList<Integer> arr = new ArrayList<Integer>(3); // Adding elements to the ArrayList arr.add(10); arr.add(20); arr.add(30); System.out.println("" + arr); // Getting the element at index 2 int e = arr.get(2); System.out.println("The element at index 2 is " + e); } }
🌐
Codecademy
codecademy.com › docs › java › arraylist › .get()
Java | ArrayList | .get() | Codecademy
February 1, 2023 - The .get() method retrieves the element at some index in an ArrayList.
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › home › java/util › java arraylist get() method
Java ArrayList get() Method
September 1, 2008 - The Java ArrayList get(int index) method returns the element at the specified position in this list.
🌐
W3Schools
w3schools.com › java › java_arraylist.asp
Java ArrayList
To access an element in the ArrayList, use the get() method and refer to the index number:
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-arraylist-get-method-example
Java ArrayList get() Method example
September 11, 2022 - package beginnersbook.com; import java.util.ArrayList; public class GetMethodExample { public static void main(String[] args) { ArrayList<String> al = new ArrayList<String>(); al.add("pen"); al.add("pencil"); al.add("ink"); al.add("notebook"); al.add("book"); al.add("books"); al.add("paper"); al.add("white board"); System.out.println("First element of the ArrayList: "+al.get(0)); System.out.println("Third element of the ArrayList: "+al.get(2)); System.out.println("Sixth element of the ArrayList: "+al.get(5)); System.out.println("Fourth element of the ArrayList: "+al.get(3)); } }
🌐
Processing
processing.org › reference › arraylist
ArrayList / Reference / Processing.org
For example, the length of the ... add() method and is deleted with the remove() method. The get() method returns the element at the specified position in the list....
🌐
Vultr
docs.vultr.com › java › standard-library › java › util › ArrayList › get
Java ArrayList get() - Retrieve Element | Vultr Docs
September 27, 2024 - The get() method in Java's ArrayList provides a simple yet powerful way to retrieve an element from a specified position in the list. This method is a part of the java.util.ArrayList class, which implements the List interface.
🌐
Oracle
docs.oracle.com › en › java › javase › 20 › docs › api › java.base › java › util › ArrayList.html
ArrayList (Java SE 20 & JDK 20)
July 10, 2023 - The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation. Each ArrayList ...
🌐
Programiz
programiz.com › java-programming › library › arraylist › get
Java ArrayList get()
import java.util.ArrayList; class Main { public static void main(String[] args) { // create an ArrayList ArrayList<String> languages = new ArrayList<>(); // insert element to the arraylist languages.add("JavaScript"); languages.add("Java"); languages.add("Python"); System.out.println("Programming Languages: " + languages); // access element at index 1 String element = languages.get(1); System.out.println("Element at index 1: " + element); } }
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › util › ArrayList.html
ArrayList (Java SE 21 & JDK 21)
January 20, 2026 - The size, isEmpty, get, set, iterator, and listIterator operations run in constant time. The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation. Each ArrayList ...
🌐
Java Development Journal
javadevjournal.com › home › arraylist get() method
ArrayList get() Method | Java Development Journal
July 13, 2021 - In this article, we will look at the ArrayList get() method. We will learn how to get an element from a specific index from the ArrayList using the ArrayList.get() method. ... Read more
🌐
Codecademy
codecademy.com › docs › java › arraylist › .indexof()
Java | ArrayList | .indexOf() | Codecademy
February 12, 2023 - The .indexOf() method returns the index of the first occurrence of the specified element in an ArrayList.
🌐
Reddit
reddit.com › r/javahelp › getting values in an arraylist in java
r/javahelp on Reddit: Getting Values in an ArrayList in Java
December 11, 2022 -

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;

}

Top answer
1 of 2
3
You're creating an array with length z, which is zero. In order to have an element at index zero, the length must be >= 1.
2 of 2
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.