





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






H. Schwartz
COP 3330 – Fall 2006
COP 3330 – Fall 2006
COP 3330 – Fall 2006
int[] numbers = new int[10];//creates a new array of integers String[] sentences = new String[5]; //creates an array of refrences to Strings //the Strings themselves have not been created yet
COP 3330 – Fall 2006
File []files = new File[3];//creates an array of files //create File objects for given files / directories files[0] = new File(“something.txt”); files[1] = new File(“/home/user”); files[2] = new File(“/home/user/oop.txt”);
//perform File instance methods on objects: if (files[0].exists()) System.out.prinln(“it exists”); String []fNames = files[1].list();//lists contents on directory files[2].setLastModified(123154623);
COP 3330 – Fall 2006
//computes how many integers are greater than 50 in intAr int numGreater = 0; for (int i = 0; i < intAr.length; i++){ if (intAr[i] > 50) numGreater++; }
//equivalent: for (int num: intAr){ if (num > 50) numGreater++; }
COP 3330 – Fall 2006
COP 3330 – Fall 2006
COP 3330 – Fall 2006
COP 3330 – Fall 2006
public class UsesAnArrayList{
private ArrayList
public UsesAnArrayList(){ //constructor intList = new ArrayList
Tangent: Java Number classes
COP 3330 – Fall 2006
COP 3330 – Fall 2006