Here's the sample code:
public static BaseListAdapter<? extends Item> getListAdapter() {
...
}
...
public class MyClass<T extends Item> {
...
BaseListAdapter<T> adapter = (BaseListAdapter<T>) getListAdapter();
...
}
The compiler complains that there's an unchecked cast.
java: unchecked cast
need: BaseListAdapter<T>
found: BaseListAdapter<capture#1, ? extends Item>
I want to know why this warning is produced and how to resolve it.
You probably want
public static <T extends Item> BaseListAdapter<T> getListAdapter() {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With