3

There are several threads regarding:

Non-static method cannot be referenced from a static context

but the question here is a bit different. I noticed that with raw type I don't get this compilation error. On the other hand if I use the wildcard I get the error. Here the code I'm talking about:

Map<Class<? extends MySuperClass<?>>, List<MySuperClass<?>>> groupedSubClasses = 
    ids.stream().collect(groupingBy(MySuperClass::getClass));

This code won't compile because of the above error. Instead:

Map<Class<? extends MySuperClass>, List<MySuperClass>> groupedSubClasses = 
        ids.stream().collect(groupingBy(MySuperClass::getClass));

will compile.

So what is the "relation" between this error and raw type/wildcard?

SGiux
  • 619
  • 3
  • 10
  • 34

0 Answers0