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

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

ubuntu - Bash Script to Check That Files Are Being Created -