Java: Retrieve an element from a given array list
Write a Java program to retrieve an element (at a specified index) from a given array list.
Pictorial Presentation:

Sample Solution:-
Java Code:
Sample Output:
[Red, Green, Orange, White, Black] First element: Red Third element: Orange
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Java program to retrieve an element at a given index and handle IndexOutOfBoundsException if the index is invalid.
- Write a Java program to retrieve multiple elements from an ArrayList based on an array of indices provided by the user.
- Write a Java program to retrieve an element at a specified index using Java streams and Optional to handle missing values.
- Write a Java program to retrieve the last element of an ArrayList by calculating its size dynamically.
Go to:
Java Code Editor:
Contribute your code and comments through Disqus.
PREV : Insert an element into the array list at the first position.
NEXT : Update specific array element by given element.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.