69.3k views
0 votes
Which method will return the first element in an ArrayList employees?

employees.first()
employees.get(1)
employees.get(0)
employees.get()

User Jimmy C
by
6.1k points

1 Answer

2 votes

Answer:

employees.get(0)

Step-by-step explanation:

In the programming, the index of ArrayList start from zero.

So, the element start storing in the ArrayList from the zero index.

get() is the function which is used to retrieve or getting the value in the

ArrayList.

The function employees.get(0), it retrieve the element of zero index.

The function employees.get(1), it retrieve the element of first index.

The function employees.first(1), it is wrong calling.

The function employees.get(), it is wrong calling. you have to enter the index value inside the get().

User Kevtrout
by
5.3k points