COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
How do you get the third element of an ArrayList?(Remember zero-indexing!)
|
list.find(2);
|
|
list.get(3);
|
|
list.find(3);
|
|
list.get(2);
|
Explanation:
Detailed explanation-1: -if i have 10 elements in a Arraylist how can i get 5th element? You can use get(index) method to access any element in arraylist. simply use get method.
Detailed explanation-2: -The index of a particular element in an ArrayList can be obtained by using the method java. util. ArrayList. indexOf().
There is 1 question to complete.