posted 18 years ago
hi guys, I am practising with Trees
The code below is belong to a class called BinaryTree
please take a look at the bold portion, i did a Customer casting. As a result, this method is not generic and robust anymore because the whole BinaryTree class can only be used on Customer class but not other classes.
My searchkey is Comparable type which is used to uniquely identify the class.
what should i do so that I no need to use (Customer) casting??
I tried using tmpn1.getClass() tmpn1.getItem()).setKey((Comparable) (v1+v2)); but it doesn;t work.