Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsSingletonMapExample3 { public static void main(String[] args) { System.out.println("Enter the key and value: "); Scanner sc = new Scanner(System.in); int key = sc.nextInt(); int value = sc.nextInt(); System.out.println("Output: "+Collections.singletonMap(key, value)); sc.close(); } }
Output