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 <K, V> K getFirstKey(Map<K, V> map, V value) {
        K ret = null;
        if (map != null && value != null) {
            for (Map.Entry<K, V> entry : map.entrySet()) {
                if (value.equals(entry.getValue())) {
                    return entry.getKey();
                }
            }
        }
        return ret;
    }
}