Type Casting Help
I believe this is a problem with Type casting but I am not sure. I have a LinkedList class that I have created which stores nodes of type Object. I am building a print queue that uses the list and stores an Object of type printdata in the nodes. This line of code here gives me the following error message:
Type mismatch: cannot convert from Object to PriorityQ.printdata
printdata temp = L1.getNode(0);
I assume that I need to type cast but I don't know how.
stores an Object of type printdata
Try declaring/adding this "printdata" as the type instead of Object.
LinkedList<printdata> list = ...
Try the following cast:
I hope this does the trick. ;)
printdata temp =[COLOR="RoyalBlue"] (printdata) [/COLOR]L1.getNode(0);