Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.HashMap;

public class Main {
    @SafeVarargs
    public static <T> HashMap<T, T> kvMap(T... kvPairs) {
        HashMap<T, T> map = new HashMap<>();
        for (int i = 0; i < kvPairs.length; i += 2) {
            map.put(kvPairs[i], kvPairs[i + 1]);
        }
        return map;
    }
}