Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generic types in Java

Tags:

java

generics

Is it right that this code

List<Integer> test2 = new ArrayList<Integer>();
test2.add(343);
int x2 = test2.get(0);

in compile time will be converted to this

List test = new ArrayList();
test.add(343);
int x = (Integer)test.get(0);

Something similar with autoboxing...

like image 314
Shikarn-O Avatar asked Sep 20 '26 12:09

Shikarn-O


1 Answers

Yes, except that "test2.add(343);" will not change to "test.add(43);"

like image 58
DwB Avatar answered Sep 23 '26 00:09

DwB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!