21.1k views
1 vote
how to create use an array of Course objects instead of individual objects like course 1, course 2, etc

User Ray K
by
4.2k points

1 Answer

1 vote

Answer:

To save the course object instances in an array, use;

Course[] courses = new Course[7];

courses[0] = new Course("IT 145");

courses[1] = new Course("IT 200");

courses[2] = new Course("IT 201");

courses[3] = new Course("IT 270");

courses[4] = new Course("IT 315");

courses[5] = new Course("IT 328");

courses[6] = new Course("IT 330");

Step-by-step explanation:

The java statement above assigns an array of size 7 with the course class constructor, then order courses are assigned to the respective indexes of the new array.

User Steven Striga
by
5.3k points