Question: Create a project called Q4A and a class called Q4A. Upload the following interface and implement the interface within the class: import java.util.ArrayList; public interface

Create a project called Q4A and a class called Q4A. Upload the following interface and implement the interface within the class:

import java.util.ArrayList;

public interface IQ4A {

// Method: dupEachChar

public String dupEachChar(ArrayList str);

}

public String dupEachChar (ArrayList str)

To solve dupEachChar, you must use recursion. UNDER NO CIRCUMSTANCES SHOULD YOU USE A LOOP, an instance variable (non-static), or a Class variable (static). We will search for all as part of the grading, any loops or global variables that are found will result in a zero for the entire quiz.

This method takes a non-null ArrayList of characters and returns a string that consists of two of each of the characters contained in the ArrayList in the order contained in the ArrayList. In addition, these duplicates are added to the ArrayList. If the ArrayList is empty, an empty string is returned and no characters are added to the ArrayList.

Example (note the ' and " below are used to denote contents and are not part of the data):

If an ArrayList containing 'a',' b', and is passed to the method, the method would have a return value of "aabbcc" back as a String. In addition, the ArrayList would now have 6 elements instead of 3 matching each of the characters in the return string and in the same order.

When you have completed your code and unit tested it to your satisfaction, you should submit the final version Q4A.java

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!