is there any difference between :
TreeMap<String, String> myMap = new TreeMap<>();
and
TreeMap<String, String> myMap = new TreeMap<String,String>();
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
They are the same in java 7 where the diamond operator
<>was introduced. In older versions of java the diamond operator will not work.The diamond operator brings type inference to constructors. Type inference on generic methods is available in java 5 and higher. Prior to java 7, to create a generic class using the compiler’s type inference you had to use generic factory methods like
static <K,T> Map<K,T> createMap().