public static int sum(Listlist){int sum = 0;for( Iterator iter= list.iterator();iter.hasNext();-){int i = ((Integer)iter.next()).intValue();sum+= i;}return sum;}What three changes allow the class to be used with generics and avoid anunchecked warning?1) Remove line 42) Replace line 4 with "int i = iter.next();"3) Replace line 3 with "for (inti :intList){114) Replace the method declaration with "sum(List intList)".
Answers
Answered by
1
Step-by-step explanation:
int sum=0;
for(iterator iter=list.iterator();
iter.hasNext();
Similar questions
Math,
30 days ago
Physics,
2 months ago
Computer Science,
2 months ago
Math,
9 months ago
Hindi,
9 months ago