看着Linkedlist.java,我觀察到重載的構造函數,其中一個包含一個空的this()。 通常我已經看到這與默認參數。這個()沒有參數的用法是什麼?在linkedlist.java中使用this()是什麼
/**
* Constructs an empty list.
*/
public LinkedList() {
}
/**
* Constructs a list containing the elements of the specified
* collection, in the order they are returned by the collection's
* iterator.
*
* @param c the collection whose elements are to be placed into this list
* @throws NullPointerException if the specified collection is null
*/
public LinkedList(Collection<? extends E> c) {
this();
addAll(c);
}
這是一個沒有參數的構造函數的調用,在這種情況下是no-op。 –
在這種情況下不需要。 –
我需要它。 –