Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;

import java.util.Map;

public class Main {
    @SuppressWarnings("unchecked")
    public static <K, V> Map<K, V> castMap(Object obj) {
        if (obj == null) {
            return new HashMap<K, V>();
        }

        if (obj instanceof Map) {
            return (Map<K, V>) obj;
        } else {
            throw new IllegalArgumentException("Expected [" + obj + "] to be a Map");
        }
    }
}