Slaxmi Raj wrote:Thank you for your reply and please tell why we create
,and it not accepting implictly.?
Because all integer literals (unless they have an 'L' after them) are ints. The compiler can work out that for
new Gen1<Integer>(99); it needs to autobox the 99, but
new Gen1<Byte>(25); requires both a narrowing conversion AND boxing, and that it can't do.
And BTW, you don't need to use new Byte(25) (and certainly notnew Byte("25")); use Byte.valueOf(25). Much better.
Joined: Apr 20, 2012
Thank you so much ,my doubt was clear..