-3
Это мой код:как я возвращать число вхождений буквы с
public int frequency (char c)
{
int numOccurrences = 0;
String ltr = "letters";
ltr = ltr.toLowerCase();
for (int i = 0; i < ltr.length(); i++)
{
if (l.charAt(0) == l.charAt(1))
{
numOccurrences = numOccurrences + 1;
}
}
return numOccurrences;
}
public class TextAnalyser
{
private int letters; // the total number of letters analysed
private int[] frequencies; // the number of occurrences of each letter of the alphabet (case-insensitive)
// initialise the instance variables
public TextAnalyser()
{
this.letters = 0;
this.frequencies = new int[26];
}
public TextAnalyser(String initial)
{
this.letters = 0;
this.frequencies = new int [26];
this.analyse(initial);
}
}
Пожалуйста, отформатируйте код. – Akah
Я не знаю, но я чувствую, что половина вашего кода отсутствует в вопросе. – SomeJavaGuy
'if ((c) == l.charAt (i)) { numOccurrences = numOccurrences + 1; } ' – ashwinbhy