Arayüz şöyle. List , Deque arayüzleri artık SequencedCollection arayüzünden kalıtıyor
interface SequencedCollection<E> extends Collection<E> {// new methodSequencedCollection<E> reversed();// methods promoted from Dequevoid addFirst(E);void addLast(E);E getFirst();E getLast();E removeFirst();E removeLast();}
getFirst metodu
Eskiden şöyle yapmak gerekiyordu
// First Element list.get(0)
Artık şöyle yaparız
list.getFirst()
getLast metodu
Eskiden şöyle yapmak gerekiyordu
// Last Element list.get(list.size()-1)
Artık şöyle yaparız
list.getLast()
reversed metodu
Açıklaması şöyle. Yani SequencedMap, SequencedSet gibi arayüzler SequencedCollection değil kendi tiplerini dönüyorlar
Covariant Return Types is an important Java feature that I feel has gotten less coverage than the others listed above. The addition of Sequenced Collections in Java 21 brings some recent attention to this important feature that was added in Java 5. The SequencedCollection interface has a method named reversed that has covariant overrides with more specific return types in SequencedSet, Deque, List, etc.
Hiç yorum yok:
Yorum Gönder