Este enunciado ha sido aprobado por especialistas así se garantiza la veracidad de nuestro contenido.
Ejemplo 1: linkhashmap en java
LinkedHashMap is same as HasHMap just additionally maintains the insertion order.
Ejemplo 2: mapa hash y mapa hash vinculado
Main difference between HashMap and LinkedHashMapI remember is that LinkedHashMap maintains
insertion order of keys,On the other hand HashMap doesn't maintain
any order or keys or values.
AlsoLinkedHashMaprequiresmore memory than HashMap
because of the ordering feature.
LinkedHashMap doublly LinkedListtomaintain order of elements.
Ejemplo 3: linkhashmap en java
LinkedHashMap can have null key, keeps order
Ejemplo 4: LinkedHashSet en java
importjava.util.LinkedHashSet;publicclassLinkedHashsetExamplepublicstaticvoidmain(String[] args)LinkedHashSet<String> lhs =newLinkedHashSet<String>();// add elements to LinkedHashSet
lhs.add("Anteater");
lhs.add("Bear");
lhs.add("Cheetah");
lhs.add("Deer");// will not add new element as Anteater already exists
lhs.add("Anteater");
lhs.add("Elephant");System.out.println("LinkedHashSet size: "+ lhs.size());System.out.println("Given LinkedHashSet: "+ lhs);System.out.println("Deer removed from LinkedHashSet: "+ lhs.remove("Deer"));System.out.println("Remove Zebra which is not present: "+ lhs.remove("Zebra"));System.out.println("Check if Anteater is present: "+ lhs.contains("Anteater"));System.out.println("New LinkedHashSet: "+ lhs);
Te mostramos reseñas y puntuaciones
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)