How do you implement the Comparable interface inside of a custom class?
Posted on 2006-11-28
Thanks for taking the time to help. Allow me to explain the situation:
I have a "dog" class. Somehow, I need to create a subclass that extends the java's "Comparable" class so that "dog"s can be compared.
The reason I need to do this is because I have a tree that is going to be built up of dogs. However, the tree's "find" feature needs to be able to access the Comparable "something (i dont know what you would call this)" in order to traverse the tree.
So, can someone please explain to me how I would go about implementing the Comparable "(something, i think you cal it a subclass?)" into my "dog" class so that I can achieve my desired outcome?
Thanks for the help,
an aspiring java learner