Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HashMap<String, Vehiculo> hashMap = new HashMap<>();
- hashMap.put("1ABC", new Vehiculo("1ABC","fiat"));
- hashMap.put("2ABC", new Vehiculo("2ABC","fiat"));
- hashMap.put("3ABC", new Vehiculo("3ABC","mercedes"));
- hashMap.put("2ABC", new Vehiculo("2ABC","ferari"));
- Vehiculo vehiculo = hashMap.get("1ABC");
- boolean encontrado = hashMap.containsKey("1ABC");
- hashMap.remove("2ABC");
- //diccionario (mapa, clave-valor) -> conjunto (set, corral) -> tabla
- Iterator it = hashMap.entrySet().iterator();
- while (it.hasNext())
- {
- Map.Entry<String, Vehiculo> filaTabla = (Entry<String, Vehiculo>) it.next();
- System.out.println(filaTabla.getKey());//soy la clave
- System.out.println(filaTabla.getValue()); //soy el valor
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement