Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("CSS", "style");
        map.put("HTML", "mark up");
        map.put("Oracle", "database");
        map.put("XML", "data");

        printDetails(map);
        map.clear();
        printDetails(map);
    }

    public static void printDetails(Map<String, String> map) {
        String usage = map.get("CSS");
        System.out.println("Map: " + map);
        System.out.println("Map Size:  " + map.size());
        System.out.println("Map is empty:  " + map.isEmpty());
        System.out.println("Map contains CSS key:   " + map.containsKey("CSS"));
        System.out.println("Usage:  " + usage);
        System.out.println("removed:  " + map.remove("CSS"));
    }
}