java - Declaring Linked Lists of a certain data type? -
sup guys reading things linked lists , stumbled along question:
following valid or invalid statement? explain answer. (we can assume using generics)
linkedlist <int> thelist = new linkedunorderedlist <int> ();
** think it's valid statement because autoboxing occurs when declare int put list. meaning int becomes object of type int.
just want check of here if correct.or understanding of off.
you incorrect.
java generics work on objects. since int
primitive not work.
as auto unboxing, occurs integer type when try , place int in int.
Comments
Post a Comment