Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment