Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Map;

public class Main {
    public static <T> T getMapOnlyValue(Map<? extends Object, T> map) {
        if (map.size() != 1) {
            throw new IllegalArgumentException("Can't get map only value, it has " + map.size() + " elements");
        }
        return map.values().iterator().next();
    }
}