Is this a simple way to return the number of occurrences of theValue in a bag?
/**
* Return the number of occurrences of theValue in the bag.
*/
public int countOccurrences( String theValue ) {
// fill in code
for(int index = 0; index <= topPosition; index++ )
if(contents[index] == theValue)
return index;