Question: Assuming we have an ArrayList ArrayList aList = new ArrayList (); aList.add(10.0); //this works aList.add(10); //this will not work Explain why the add() function

Assuming we have an ArrayList ArrayList aList = new ArrayList (); aList.add(10.0); //this works aList.add(10); //this will not work Explain why the add() function works in the first case but fails in the second case. Is there any problem with casting?
Step by Step Solution
3.50 Rating (163 Votes )
There are 3 Steps involved in it
In Java ArrayList is a generic class meaning it can store objects of a specified ... View full answer
Get step-by-step solutions from verified subject matter experts
