I've got my compiler warning me of unnecessary casts, and this method generates one of the warnings:
public static<T> T doIt(T input) {
Object result = null;
return (T) result; // Warning: Unnecessary cast to type T for expression of type Object
}
Can anybody explain why it doesn't like me casting to type T? I get a compiler error if I don't make the cast.
Thanks.