Menu
Topics Index
...
`

Creating ArrayList and foreach loop


If you need explanation Read this topic

If you need Answer Take test on this topic

Creating ArrayList and foreach loop
Which of the following declaration will help the program without errors?
import java.util.*;

public class DemoOnLists {
    public static void main(String args[]) {
        //LINE A
        for (int i = 0; i < 10; i++) {
            ArrayList<Integer> myList = new ArrayList<Integer>();
            for (int j = 0; j < 10; j++)
                myList.add(i * j);
            container.add(myList);
        }
        for (List<Integer> value : container) {
            System.out.println(value);
        }
    }
}

A. List<List<Integer>> container = new List<List<Integer>>();
B. ArrayList<ArrayList<Integer>> container = new ArrayList<ArrayList<Integer>>();
C. List<List,Integer> container = new ArrayList<List,Integer>();
D. None of the above
Topic: Java ArrayList

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

b is the answer since it makes compatiblewith the args paased to arraylist

Posted by Karteek Paruchuri    2013-07-23 08:38:19


e

Posted by Aruna Dantu    2013-07-23 15:31:05


Congratulations Karteek Paruchuri, you are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-07-24 04:42:49


got the RC thankyou meritcampus

Posted by Karteek Paruchuri    2013-07-27 05:40:07


© meritcampus 2019

All Rights Reserved.

Open In App