Skip to content
Advertisement

Incompatible types : Int cannot be converted to “class” data type

I’m trying to insert value to a List using loop for, but this list data type is a class which have constructor in it. Here is my code :

JavaScript

And the error message on line edge.add(x,y) it says :

Incompatible data types : int cannot be converted to Edge

Here is the Edge Class :

JavaScript

What should i change? Thank you.

Advertisement

Answer

Changing edge.add(x,y) to edge.add(new Edge(x,y)) should help. The list edge expects an Object of class Edge, while two ints are being passed, causing the error.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement