DownCast or Upcast from type Node<E> to Object
Posted on 2007-03-17
In java I am trying to implement a new LinkList class that implements the iterator interface so only using iterator. The problem is I want to cast whatever type the instance of the Node is like say of type <Integer>. In my class the type that needs to be cast is not determined until the tester creates an LinkedList of a certain type with that certian Node type. I need some sort of downcast from type Object to whatever type is neded I have an instance field that is type <E> just need some downcast help.
private Node <E> Item;
//initialazation of instance field in constructor
//Something like this I think
Item = (E) new Object<Node>;//I don't know how? please help thanks