Question: Consider the following class: public class Sequence { private ArrayList values; public Sequence() { values = new ArrayList (); } public void add(int n) {
Consider the following class:
public class Sequence
{
private ArrayList
public Sequence() { values = new ArrayList
public void add(int n) { values.add(n); }
public String toString() { return values.toString(); }
}
Add a method public Sequence append (Sequence other) that creates a new sequence, appending this and the other sequence, without modifying either sequence. For example, if a is 1 4 9 16 and b is the sequence 9 7 4 9 11 then the call a.append (b) returns the sequence 1 4 9 16 9 7 4 9 11 without modifying a or b.
Step by Step Solution
3.44 Rating (157 Votes )
There are 3 Steps involved in it
To create an append function that doesnt modify either of the existing sequences you will ... View full answer
Get step-by-step solutions from verified subject matter experts
