Question: using e7.20, Complete e7.21 in Java .E7.20 Consider the following class: public class Sequence { private ArrayList values; public Sequence() { values = new ArrayList

 using e7.20, Complete e7.21 in Java .E7.20 Consider the following class:

public class Sequence { private ArrayList values; public Sequence() { values =using e7.20, Complete e7.21 in Java

.E7.20 Consider the following class: public class Sequence { private ArrayList values; public Sequence() { values = new ArrayList(); } public void add(int n) { values.add(n); } public String toString() { return values.toString(); } } ** E7.21 Add a method public Sequence merge(Sequence other) to the sequence class of Exercise E7.20 that merges two sequences, alternating ele- ments from both sequences. If one sequence is shorter than the other , then alternate as long as you can and then append the remaining elements from the longer sequence. For example, if a is 1 4 9 16 and bis 9 7 4 9 11 then a merge(b) returns the sequence 1 9 4 7 9 4 16 9 11 without modifying a or b

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!