I need to finish a program that would take a string for example: "Mass" and would return the output somewhat like this:
M's: 1 A's: 1 S's: 2
I need to create a method that takes only one string parameter and returns an array of an object called Pair. The pair object is what i had output of above. each element in Pair contains a character and the number of occurrences of that character. This is the pair class:
public static class Pair
{
public char _char;
public int _occurances;
public Pair(char c)
{
_char = c;
_occurances = 0;
}
}
This is the method I am working on:
public Pair[] auditString(String input) {
return Pairs;
}
How can I make this method auditString work if I were to input "Mass" and my method returned an array of pair with this data:
pairs array would generate 3 memory locations
pairs at element 0 has character m with 1 occurrence, pairs at element 1 has character a with 1 occurrence, and pairs at element 2 has character s with 2 occurrences