Top
Previous Next
Java Arrays, Objects, Methods CS 161 - Java

Creating collections of objects

Several ways to create a group of objects, all of the same type:

Individual instance variables:

Student aStudent;
Student anotherStudent;
Student yetAnotherStudent;
...
aStudent = new Student();
aStudent.setName("Fred Flintstone");
anotherStudent = new Student();
anotherStudent.setName("Wilma Flintstone");
yetAnotherStudent = new Student();
yetAnotherStudent.setName("Barney Rubble");

Arrays

To be discussed in a few minutes

One of Java's "Collections" classes


java.util.Vector;
java.util.Hashtable;

java.util.LinkedList;
java.util.HashMap;
java.util.ArrayList;
We won't be covering the Collection classes in this course.
Top
Previous Next
jwd