I have some code in Java as follows:
private Object addVertex(String label, int posX, int posY) {
Vertex newVertex = new Vertex();
this.getModel().beginUpdate();
try {
newVertex = insertVertex(parent, null, label, posX, posY, 80, 30);
}
finally {
this.getModel().endUpdate();
}
return newVertex;
}
That code wont work because of a type mismatch, insertVertex will return an Object, but I get a type mismatch since it can't convert from Object to Vertex (which is an object I created).
Firstly, how come that can't work, since the object Vertex inherits Object by default surely you should be able to do that.
Also, if I try and type cast the Object to a Vertex as follows
newVertex = (Vertex) insertVertex(parent, null, label, posX, posY, 80, 30);
I get an error saying I can't make that conversion.