idzik icon

Java-Kolekcje-HashMapa.java

idzik | PRO | 01/27/16 01:28:39 PM UTC | 0 ⭐ | 287 👁️ | Never ⏰ | []
Java |

610 B

|

None

|

0 👍

/

0 👎

import java.util.HashMap;
import java.util.Map;
 
public class HashMapa {
 
    public static void main(String[] args) {
        HashMap<Integer, String> mapa = new HashMap<Integer, String>();
        mapa.put(1, "jeden");
        mapa.put(2, "dwa");
        mapa.put(3, "trzy");
        mapa.put(4, "cztery");
        mapa.put(5, "piec");
        mapa.put(6, "szesc");
        mapa.put(6, "sz");
 
        String lancuch = mapa.get(6);
        System.out.println(lancuch);
        // wyświetlenie wszsytkich elementów mapy
 
        for (Integer key : mapa.keySet()) {
            String value = mapa.get(key);
            System.out.println("Klucz " + key + ", wartość " + value);
        }
 
    }
 
}

Comments