Create singleton map - Java java.util

Java examples for java.util:Collection Creation

Description

Create singleton map

Demo Code


//package com.java2s;

import java.util.Collections;

import java.util.Map;

public class Main {
    public static <K, V> Map<K, V> map1(K key, V value) {
        return Collections.singletonMap(key, value);
    }/* ww  w .  j a  va  2s  .c  o  m*/
}

Related Tutorials