http://stackoverflow.com/questions/5207115/java-generics-t-vs-object
What is the difference between the two ?
public Object doSomething(Object obj) {....}
public T doSomething(T t) {....}
compile time safety that that like works. If the
What is the difference between the two ?
public Object doSomething(Object obj) {....}
public T doSomething(T t) {....}
compile time safety that that like works. If the
Object
version is ued, you won't be sure if the method always returns Foo
. If it returns Bar
, you'll have a ClassCastException
, at runtime.
No comments:
Post a Comment