I am trying to get this to work and am stuck. I run a JUnit test and get a few failures. Can someone show me the way to make this work?
/**
* int numberOf(String s, String characters)
*
* Returns the number of times any of the chars in the second String occur in the first String
*
* if s is "", then no matter what characters is the answer is 0 (zero)
* if s is "abcdefg", and characters is "f", then the correct answer is 1
* if s is "farfalle", and characters is "alf", then the correct answer is 6
*
* Some examples:
*
* The only methods you may call on either String are charAt(int) and length().
*
* @param s is the original String
* @param characters is the String whose constituent character counts in s we want to determine
* @return the number of occurrences of the chars in characters in s
*/
public int numberOf(String s, String characters)
{
int totalchar = characters.length();
int a =0;
for (int t=0;t<characters.length();t++)
{
if (s.charAt(t)== characters.charAt(t))
a++;
}
return a;