Mega Code Archive

 
Categories / Java Tutorial / Generics
 

A generic type can accept more than one type variables

import java.util.HashMap; import java.util.Map; public class MainClass {     public static void main (String[] args) {         Map<String, String> map = new HashMap<String, String>();         map.put ("key1", "value1");         map.put ("key2", "value2");         String value1 = map.get("key1");     } }