Created
August 10, 2010 00:58
-
-
Save mapiondev/516415 to your computer and use it in GitHub Desktop.
[java] コレクションをシンプルに宣言する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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