Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package generatorr;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.LinkedHashMap;
- import java.util.Map;
- import java.util.Map.Entry;
- import java.util.TreeMap;
- /**
- *
- * @author Dany presentame a tu hermana xfa uewe
- */
- public class MapP {
- public static void main(String[] args) {
- Map<Integer, String> map = new HashMap<Integer, String>();
- map.put(4, "Lopez");
- map.put(90, "Chavez");
- map.put(15, "Ramirez");
- map.put(3, "Dany");
- map.put(15, "Naie Trejo");
- map.put(4, "Dany presenatme a tu hermana");
- map.put(9, "Hola prros");
- map.put(8, "Puytol");
- Map<Integer, String> map2 = new TreeMap<Integer, String>();
- map2.put(4, "Lopez");
- map2.put(90, "Chavez");
- map2.put(15, "Ramirez");
- map2.put(3, "Dany");
- map2.put(4, "Dany presenatme a tu hermana");
- map2.put(9, "Hola prros");
- map2.put(8, "Puytol");
- Map<Integer, String> map3 = new LinkedHashMap<Integer, String>();
- map3.put(4, "Lopez");
- map3.put(90, "Chavez");
- map3.put(15, "Ramirez");
- map3.put(3, "Dany");
- map3.put(4, "Dany presenatme a tu hermana");
- map3.put(9, "Hola prros");
- map3.put(8, "Puytol");
- Iterator it = map.keySet().iterator();
- while (it.hasNext()) {
- Integer key = (Integer) it.next();
- System.out.println("Clave: " + key + " Valor: " + map.get(key));
- }
- System.out.println("===================");
- Iterator it2 = map2.keySet().iterator();
- while (it2.hasNext()) {
- Integer key = (Integer) it2.next();
- System.out.println("Clave: " + key + " Valor " + map2.get(key));
- }
- System.out.println("===================");
- Iterator it3 = map3.keySet().iterator();
- while (it3.hasNext()) {
- Integer key = (Integer) it3.next();
- System.out.println("Clave: " + key + " Valor " + map3.get(key));
- }
- System.out.println("============================\n");
- System.out.println("Dimension map: "+map.size());
- System.out.println("Esta vacio? "+map.isEmpty());
- System.out.println("Eliminar el item: 90 "+map.remove(90));
- System.out.println("Mensaje de error cuando no existe un item: "+map.get(90));
- System.out.println("Buscar si existe un elemento con la clave 90 "+map.containsKey(90));
- System.out.println("Buscar a la hermana de daniel en el arbol: "+map.containsValue("Naie Trejo"));
- System.out.println("Le daremos en la madre al arbol: "); map.clear();
- String res = (map.isEmpty()) ? "A huevo" : "Pos no";
- System.out.println("Si se vacio? "+ res);
- for(Entry<Integer, String> tmp : map2.entrySet()){
- Integer key = tmp.getKey();
- String valor = tmp.getValue();
- System.out.println("Clave: "+key+" Valor: "+valor);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement