1. I have a class named 'node' and a vector made up of nodes. When I use a vector method like lastElement(), an Object is returned, not a node. However, I need a node to manipulate with as a result of this method call - for eg, I assign the node that I would like returned from the method to a newly created node. How do I tackle this?
2. How do I read character input from the console? i.e., objects of type 'char'?
Cast the Object type returned from lastElement() to a Node type.
A char is a standard type, not an Object or reference type. You can read them using an implementation of java.io.Reader.read() to read System.in. Like this:
If you are positive that only Nodes will be in the vector, Tim's solution is perfect. if there is ANY chance there might be something OTHER than a node in there, you may want to use the 'instanceOf' operator to make sure before you do your cast.