ArrayListSum

ArrayListSum - nbrs.add(k add up int sum = 0 int temp...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.ArrayList; import java.util.Iterator; i public class ArrayListSum { public static void main (String [] arg) { ArrayList<Integer> nbrs = new ArrayList<Integer>(); // fill in nbrs for (int k = 1; k <= 20; k++)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { nbrs.add(k); } // add up int sum = 0; int temp; for (int k = 0; k < nbrs.size(); k++) { temp = nbrs.get(k); sum += temp; } System.out.println("sum equals: " + sum); } }...
View Full Document

This note was uploaded on 06/07/2010 for the course CS 201 taught by Professor Staff during the Spring '08 term at Iona.

Ask a homework question - tutors are online