I have a list of nodes. This nodes are a data class I defined by myself. Each node has a data field of the type Object. Now I want to find the node in a list of nodes that has the parameter object in the data field. I wrote this method, because I wanted to first compare if the two objects (the parameter and the object in the data field) are of the same type:
public Node getnNodeByData(Object obj) { for (Node node : nodes) { if (node.getData() instanceof obj.getClass()) { } } } Unfortunately this condition does not work:
Incompatible operand types boolean and Class<capture#1-of ? extends Graph> I don't really know why this is a problem. How can I make this working?