I am trying to write a code to count the frequency of characters in a String;
For example if I have String str = new String("This is a test");
I want to count the number of occurrence of each character in the string.(assuming the code is case insensitive)
This is what I have at present ...
//
public static void main(String[] args)
{
// TODO Auto-generated method stub
String temp = new String("This is a test message");
//int[] alphabets = new int [26];
int [] temp1 = new int[100];
char [] s = temp.toUpperCase().toCharArray();
for(int i=0;i<s.length;i++)
{
temp1[(s-'A')]++;
}
for(int i =0;i<temp1.length;i++)
{
System.out.println(temp1);
}
}
}
}
I need help on how to complete this implementation.
Thanks in advance for your help.