Java Collections create an unmodifiable map
import java.util.Collections; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) { Map<String, String> map = createUnmodifiableMap(); map.put("CSS", "style"); }// ww w . j av a2 s . c o m public static final Map<String, String> createUnmodifiableMap() { Map<String, String> map = new HashMap<String, String>(); map.put("HTML", "mark"); return Collections.unmodifiableMap(map); } }