If there is a class such as:
public class Foo<T> {
T t;
}
and you instantiate it simply as Foo foo = new Foo();
you will only get a warning. If there is no specification of what the type is, what is the type? Object? I cannot seem to find the answer.
As an extension of this question, if I had class like so:
public final class SomeClass{
private SomeClass(){
throw new UnsupportedOperationException();
}
public static void bar(Foo foo){
}
}
It gives a warning on line public static void bar(Foo foo)
because the generic is not specified. I cannot specify the generic without getting the generic... so how would I do the equivalent of public static void bar(Foo<t> foo)
via getting the generic of foo. And no I cannot put a generic in SomeClass and use that because it is static. It is necessary for this class to be static.
-Note this isn't me wondering why it should not be used. I am aware it should be used and it is only allowed to not because of backwards compatibility. This is a question on how it will be used in this specific case.