Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.HashMap;

public class Main {
    public static void main(String[] args) {
        HashMap<String, Integer> map = new HashMap<String, Integer>();

        map.put("a", 1);
        map.put("b", 2);

        System.out.println("Before removal");
        for (String s : map.keySet()) {
            System.out.println(s);
        }

        System.out.println("\n\nAfter removal");

        map.remove("a");
        for (String s : map.keySet()) {
            System.out.println(s);
        }
    }
}