Skip to content

Instantly share code, notes, and snippets.

@mapiondev
Created August 10, 2010 00:58
Show Gist options
  • Save mapiondev/516415 to your computer and use it in GitHub Desktop.
Save mapiondev/516415 to your computer and use it in GitHub Desktop.
[java] コレクションをシンプルに宣言する
public class Generics {
public static void main(String[] args) {
List<String> oldList = new ArrayList<String>();
List<String> newlist = newList();
Map<String, String> oldMap = new HashMap<String, String>();
Map<String, String> newMap = newMap();
}
private static <E> List<E> newList() {
return new ArrayList<E>();
}
public static <K, V> Map<K, V> newMap() {
return new HashMap<K, V>();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment