Der folgende Code stammt von LinkedList.java
in 1.8
Version. Ich kann nicht verstehen, warum this()
heißt? Der Konstruktor LinkedList()
scheint nichts zu tun?Warum rufen einige Konstruktoren mit Parameter noch dieses() auf? Es scheint nichts zu tun?
/**
* 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);
}
das ruft einfach den Standardkonstruktor – Stultuske
Wo instanziieren Sie die Klasse? –
Nur Spekulation, aber ich könnte mir vorstellen, es ist eine Bestimmung für zukünftige Versionen. Vielleicht wird der Default-Ctor irgendwann "etwas tun". Dann haben Sie bereits den parametrierten ctor mit festgelegt. – Fildor