Declaring whether a class is generic or not affects other generic methods of the class (unlike generic parameters on this class)

the JDK8, code is as follows:

public class Foo<E> {

    public <T extends List> T get(T list) {
        return null;
    }

    public void pass(Foo<?> foo) {
        ArrayList arrayList = foo.get(new ArrayList());
    }

    public void broken(Foo foo) {
        //  Incompatible types,ArrayList
        ArrayList arrayList = foo.get(new ArrayList());
    }
}
The E and get methods of

Foo have different generic parameters T , so whether or not to declare Foo to be generic should not affect the get method.

is this intentional by the JAVA author for some reason, or is the compiler incapable of inference?

Sep.17,2021

this is the boundary problem of generics, and the java compiler does not allow unsafe type conversions.

the first method parameter defines Foo , telling the compiler that class generics are allowed to accept any type, so safe type conversions can be performed (actually accepting OBJECT)

the second method does not specify the generic type of Foo, so there is uncertainty about type conversion.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35781-2bf8d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35781-2bf8d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?