Java:Map
De W3API
Contenido |
[editar] Descripcion
Interface que representa un mapa de pares clave/valor. El mapa no puede contener claves duplicadas.
[editar] Sintaxis
public interface Map
[editar] Ejemplo
Map<String,String> hm = new HashMap<String,String>();
hm.put("1","Luis");
hm.put("2","Amaya");
hm.put("3","Julio");
// Añadimos un elemento con clave existente. Se sobrescribe su valor
// ya que no puede haber valores duplicados
hm.put("1","Victor");
Iterator<Entry<String,String>> it = hm.entrySet().iterator();
while (it.hasNext()) {
Entry<String,String> e = it.next();
System.out.println(e.getKey() + " " + e.getValue());
}
[editar] Campos
[editar] Metodos
- clear()
- containsKey()
- containsValue()
- entrySet()
- equals()
- get()
- hashCode()
- isEmpty()
- keySet()
- put()
- putAll()
- remove()
- size()
- values()