public static void main(String[] args) {
int count = 0;
char[] array = {'а', 'g', 'r', 'e', 'r', 's', 'a', 'х', 'ј', 'a'};
//char[] array = {'p', 'a', 'а', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'а'};
//char[] array = {'a', 'b', 'b', 'c', 'k', 'a', 'a'};
for (int i = 0; i < array.length; i++) {
if (array[i] == 'a') {
count++;
}
//System.out.println(count);
}
System.out.println("Letter 'a' " + count + " times.");
}
I have some 'specific' problem here. If I check first array, result is 2 instead 3. If I check second array, result is 8 instead 10. When I check third array, everything is OK.
You can uncomment the System.out.println(count);
line and see strange way how it wrong count.
I want to know what is problem.
Thanks in advance. Regards.