3.1 

import java.util.ArrayList;

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

 

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

x

Hi!
I'm Krystal!

Would you like to get a custom essay? How about receiving a customized one?

Check it out