Ex02 Task2.1 Type mismatch error
Verfasst: 12. Nov 2017 16:02
Hi,
I have a question with regard to Context.get() method. I am wondering how does the Java compiler cast implicitly the return type of the Supplier call value.get() whose return type is of generic type T to Object type. In fact the signature of cache.computeIfAbsent() method is given such as : Object java.util.HashMap.computeIfAbsent(String key, Function<? super String, ? extends Object> mappingFunction)
Since T is an unbound generic type, the compiler should rather raise a type mismatch error which does not occur.
Regards,
I have a question with regard to Context.get() method. I am wondering how does the Java compiler cast implicitly the return type of the Supplier call value.get() whose return type is of generic type T to Object type. In fact the signature of cache.computeIfAbsent() method is given such as : Object java.util.HashMap.computeIfAbsent(String key, Function<? super String, ? extends Object> mappingFunction)
Since T is an unbound generic type, the compiler should rather raise a type mismatch error which does not occur.
Regards,