java - SortedVector from Vector -



java - SortedVector from Vector -

(learning task - got stuck) need create class (sortedvector) extends vector sorting elements. can't figure out how overload addelement method. must utilize collections.sort.

public class sortedvector extends vector { public void addelement(object o){ super.add(o); collections.sort(); //what do here? } }

you want sort current collection - pass this collections.sort:

public class sortedvector extends vector { public void addelement(object o){ super.add(o); collections.sort(this); // note usage of } }

java inheritance vector overloading method-overloading

Comments

Popular posts from this blog

php - Edges appear in image after resizing -

ios8 - iOS custom keyboard - preserve state between appearances -

Delphi change the assembly code of a running process -