Question: Provide a more compact (but functionally equivalent) version of this code fragment: ArrayList students = new ArrayList (); Student student1 = new Student (Alex Trotsky,

Provide a more compact (but functionally equivalent) version of this code fragment:

ArrayList students = new ArrayList (); Student student1 = new Student ("Alex Trotsky", "History");

ArrayList students = new ArrayList (); Student student1 = new Student ("Alex Trotsky", "History"); students.add(student1); Student student2 new Student ("Megan Cooper", "Computer Science"); students.add(student2);

Step by Step Solution

3.33 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a more compact version of the provided code fragment ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!