Java Collections Java Java API
java.util.Collections
public static <K,V> Map<K,V> singletonMap(K key, V value)
Returns an immutable map, mapping only the specified key to the specified value.
package com.logicbig.example.collections;import java.util.Collections;import java.util.Map;public class SingletonMapExample { public static void main(String... args) { Map<Integer, Integer> map = Collections.singletonMap(1, 4); System.out.println(map); }}
{1=4}