public class StringBag { // the array to hold the data private String [] bag; //
ID: 3914239 • Letter: P
Question
public class StringBag {
// the array to hold the data
private String [] bag;
// the number of elements being held (also the next index where a new
// String can be put).
private int count;
public StringBag(int length) {
bag = new String[length];
count = 0;
}
}
c. [2 points] Write a function that determines the index of a String in the StringBag. It should return the index if found, or -1 if it is not found. i. Write your test case for this method. @Test public void testIndexOf() { // Replace this test with your code } ii. Write your method. public int indexOf(String item) { // Replace this test with your code }
Explanation / Answer
========================================================
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.