gudii9
asked on
array list error
public static void main(String... aArgs){
List<Number> numbers = (List<Number>) new ArrayList<>();
above line giving below error. I wonder what it means. How to fix it. Please advise.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I wonder why the author did the casting orignially in the document i read. Is there is aplace or necessity of casting ArrayList to List at all?
please advise
please advise
I can't think of a situation where that cast makes sense; it may just be a typo.
Since Java version 7, you no longer have to say <Number> the second time. Instead, you can use the "diamond" operator <> and save some typing. The problem here is the cast.