I had written a class using Vector, Hashtable, TreeMap with adding
elements first using Vector class and passing the Vector instance to
Hashtable as the value and key being specified in the put() method so
that every unique key will have a group of values. Then I pass the
Hashtable instance to the TreeMap for sorting the keys and written
seperate methods for the values to be sorted.

I am getting the keys and storing them in the Object instance and
comparing that with the key just like this and if it matches I am
calling the corresponding value method to be sorted.

Object o = me.getKey();
if(o=="ATW") { cd.getAtwVectorSort(); }
else if(o=="Java") { cd.getJavaVectorSort(); }

Now my problem is I can't keep on adding if/else statements if there
are 1000 of elements to be sorted. I am looking for some other way to
solve this problem.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!