java - Difference between LinkedList of Object and a LinkedList of a HashMap? -


i coding java code , saw couldn't :

linkedlist<hashmap<string,object>> errormanagement = new linkedlist<hashmap<string, object>>(); hashmap<string,object> = new hashmap<string,object>(); errormanagement.add(i.clone()); <-- impossible add hash map here 

where getting errors if wanted add hash map linked list ...

and figured out doing in way:

hashmap<string,object> tokeninfo = new hashmap<string,object>(); linkedlist<object> errormanagement = new linkedlist<object>(); errormanagement.add(tokeninfo.clone()); <-- working charm ! 

i hadn't more errors. may explain me why ? , what's difference ?

p.s. : should ,before asks me, error thrown when adding linked list (for first example)!

the problem return type of clone(): it's object, not hashmap<string,object>. that's why second snippet works, first 1 not.

you can fix first code snippet constructing copy of hash map through constructor:

errormanagement.add(new hashmap<string,object>(i)); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -