Using the Diamond Operator for Constructor Type Inference : Diamond Operator « JDK 7 « Java






Using the Diamond Operator for Constructor Type Inference

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Test {

  public static void main(String[] args) {

    List<String> list = new ArrayList<>();

    List<Map<String, List<String>>> stringList = new ArrayList<>();

  }
}

 








Related examples in the same category

1.Using the Diamond Operator when type is not obvious
2.Using the @SafeVarargs Annotation
3.Using the Diamond Operator and Suppressing Unchecked Warnings(SuppressWarnings)