看看哪里错了
输出单词里出现最频繁的字母, 为什么程序总是瘫痪public char mostFrequent()
{
int count=0;
int maxCount=0;
char frequent='a';
char[] nameArray;
char one, two;
int l=0, p=1;
String str1=line.toLowerCase();
nameArray=str1.toCharArray();
for(int i=0; i<line.length(); i++)
{
for(int t=0; t<line.length(); t++)
{
one=nameArray[i];
two=str1.substring(l, p).toLowerCase().charAt(0);
if(one==two)
count++;
l++;
p++;
}
if(count>maxCount)
{
maxCount=count;
frequent=nameArray[i];
}
}
return frequent;
}