Good day! That's what happened with me. Displays the desired result, but after 2 cycles.
How to do with one?
public class Main { public static void main(String[] args) { int[] dArray = {20, 13, 20, 14, 20, 14}; int max = 0; int k = 0; for (int i = 0; i < dArray.length; i++) { if (max < dArray[i]) max = dArray[i]; } for (int i = 0; i < dArray.length; i++) { if (dArray[i] == max) k++; } System.out.println(k); } }