So i'm having this error in one of my projects, where I have a method which firm is Collection<Collection<String>>
and when trying to invoke it with a List<List<String>>
I get the following error
/MyClass.java:10: error: incompatible types: List<List<String>> cannot be converted to Collection<Collection<String>>
method(matrix);
This is an example of my code (not actually my code)
import java.util.Collection;
import java.util.List;
public class MyClass {
public static void main(String args[]) {
List<List<String>> matrix = List.of(
List.of("q", "w", "e", "r", "t", "y"),
List.of("1", "2", "3", "4", "5", "6")
);
method(matrix);
}
private static void method(Collection<Collection<String>> matrix){
//method here
return;
}
}
>`. Hence, they aren't compatible types.