Rachel Glenn wrote: What is causing the actual exception to be thrown to be ClassCastException? Is is trying to convert a HashTest to a String, or vice versa?
Actual ClassCastException, as mentioned in your previous error message, is while casting HashTest to Comparable.
Rachel Glenn wrote: Also, EVEN IF HashTest DID implement the Comparable interface and overrode the compareTo() function, would that need to be written to compare to a string?
Now, that's tricky. If your HashTest implements Comparable<Object>, then you must assume that other object (with which current object is being compared to) must be of type Object (which is no big deal), AND, only methods of Object class can be invoked on it.
Of course, you can cast it to HashTest and all, but be prepared for another ClassCastException.
Rule of thumb here is (ok, not exactly a thumb rule):
If you want to sort an array with objects of different classes (e.g. class X and Y), then make sure that:
1) X and Y have common parent (say Z)
2) X and Y implements Comparable<Z>
3) Z holds methods which will matter in compareTo methods of X and Y
4) Create an array of Z and put those objects of X and Y in it
This way, you won't find much trouble while sorting.
Logically, it doesn't make much sense to compare HashTest with String (ever heard of comparing apples with oranges? )