3.1 constructor using object (f) int a5 =

 

3.1 

import java.util.ArrayList;

 

public class Homework1{

 

                public
static void main(String args){

 

                                ArrayList
list = new ArrayList();

 

                                for(int
i = 0; i < 2; ++i ){                                                   for(int j = 0; j < 5; ++j){                                                   list.add(j);                                                 }                 }   System.out.print(list);                   } }     3.4   static  int sum(ArrayListplist)

{

                int sum
= 0;

                for
(Integer d:plist)

                sum =
sum + d;

                return
sum;

                }

}

 

 

3.5

 

public ArrayList arrayListCreate(int pLen,
int pInitValue){

               

                ArrayList
list = new ArrayList(pLen);

               

                for
(int i=0; i