Question: PLEASE HELP! ArrayBagDemo.java 1 import java.util.Arrays; 2 3 public class ArrayBagDemo 4 { 5 public static void main(String[] args) 6 { 7 String[] contentsOfBag =

PLEASE HELP!

PLEASE HELP! ArrayBagDemo.java 1 import java.util.Arrays; 2 3 public class ArrayBagDemo 4

ArrayBagDemo.java

1 import java.util.Arrays; 2 3 public class ArrayBagDemo 4 { 5 public static void main(String[] args) 6 { 7 String[] contentsOfBag = {"A", "A", "B", "A", "C", "A"}; 8 9 // Tests on an empty bag 10 BagInterface aBag = new ArrayBag(contentsOfBag.length); 11 System.out.println("Testing an initially empty bag:"); 12 System.out.println(aBag.isEmpty()); 13 for(String s: contentsOfBag){ 14 aBag.add(s); 15 } 16 17 System.out.println(Arrays.toString(aBag.toArray())); 18 } 19 }

Points: 100 points Problem Description: Implement a method replace for the ADT bag that replaces and returns an unspecified object currently in a bag with a given object. /** Replaces an unspecified entry in this bag with a given object. @param replacement The given object. (a) return The original entry in the bag that was replaced. */ public T replace(T replacement ) \} Test the method "replace" in the ArrayBagDemo.java. Required Submission Files: ArrayBag.java, ArrayBagDemo.java, BagInterface.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!