PowerEdgeTech
asked on
Easy ArrayList Question
Easy question:
ArrayList<String> alist = new ArrayList<String>();
ArrayList<String> alist = new ArrayList<>();
ArrayList<String> alist = new ArrayList();
All of the above SEEM to work identically. Is that indeed the case? Netbeans indicates that the first one is "redundant" and is happy with the last two. Which is most correct, or is there one that is considered just good programming practice? Is there any circumstance where one would be required over another?
ArrayList<String> alist = new ArrayList<String>();
ArrayList<String> alist = new ArrayList<>();
ArrayList<String> alist = new ArrayList();
All of the above SEEM to work identically. Is that indeed the case? Netbeans indicates that the first one is "redundant" and is happy with the last two. Which is most correct, or is there one that is considered just good programming practice? Is there any circumstance where one would be required over another?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So in 1.7, is the <> just shorthand because specifying the type again is simply redundant, and that there is never a time that the <> type in the assignment would ever differ from the <> in the declaration?Yes that's right
ASKER
Thank you :)
ASKER