Last active
December 16, 2015 09:28
-
-
Save YukiYoshikawa/5412953 to your computer and use it in GitHub Desktop.
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
package trial.yy.java7.client.collection; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Java7 ジェネリクスのダイアモンド・オペレータを試すためのサンプル | |
* User: yy | |
* Date: 13/04/18 | |
* Time: 23:01 | |
*/ | |
public class Java7CollectionClient { | |
public static void main(String[] args) { | |
// Java7だと左辺から右辺の型引数を推測してくれる | |
List<String> listJava7 = new ArrayList<>(); | |
listJava7.add("abc"); | |
listJava7.add("def"); | |
listJava7.add("ghi"); | |
System.out.println("listJava7: " + listJava7); | |
// Java6まではこんな感じ | |
List<String> listJava6 = new ArrayList<String>(); | |
listJava6.add("ABC"); | |
listJava6.add("DEF"); | |
listJava6.add("GHI"); | |
System.out.println("listJava6: " + listJava6); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment