import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] argv) { Map<String, URL> urlMap = new HashMap<String, URL>(); try { urlMap.put("java", new URL("http://www.java2s.com")); } catch (MalformedURLException e) { } String s = urlMap.get("java").getHost(); } }