What is the time complexity of LinkedList.getLast() in Java?

后端 未结 5 681
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 15:06

I have a private LinkedList in a Java class & will frequently need to retrieve the last element in the list. The lists need to scale, so I\'m trying to decide whether I

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-17 16:04

    The implementation of LinkedList.getLast() leaves no doubts - it's an O(1) operation. However, I didn't find it documented anywhere.

提交回复
热议问题