Please clarify as how line 2 and line 3 works whereas line 1 gives compiler error.
because .net guys can also write in java
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
because .net guys can also write in java
Originally posted by Noam Wolf:
you're passing o2 to ex1 which tries to add an object to o2. Remember a very important thing about extends: You can NOT add/manipulate a generic type that has extends in it! That's why line 1 is not compiling.
Thanks<br />Dinesh
SCJP 1.5 94%.
The greatest glory in living lies not in never falling, but in rising every time we fall.
AS POSTED BY NOAM
1 is not compiling because you are saying param1 should be of type
List<X> where X is a runtime type (the ? is a placeholder which is
filled in by X at runtime). Param2 is an object. Since the compiler
cannot confirm that argument2 (of type object) is of type X, it breaks
compilation.
Answer was given to me by Uber Java Engineer @ google...
If you can't be the Sun ..<br /> Be a star ..............
Don't get me started about those stupid light bulbs. |