i have a private Node class with a getValue() method that returns the Node's value which is of generic type. In another class i've tried doing this:
T tempItem = null; ----also generic
tempItem = currentNode.getValue();
I get a complier error unless I cast it like this: tempItem = (T) currentNode.getValue();
Honestly i don't understand why i need to do this or if it actually works or not. Can someone explain?
Edited 4 Years Ago by plasticfood