fork download
  1. class Ideone {
  2.  
  3. public static void main(String[] args) {
  4. int number = 0;
  5. int[] array = new int[]{10,3,0,0,2,6,7,2,0,2,-1,-3,0,0,0,0,0,2,-3,-4,-5,0,0,0,0};
  6. int count = 0;
  7. int max = 0;
  8. for (int i = 0; i < array.length; i++) {
  9. if (array[i] == number) {
  10. count++;
  11. } else {
  12. if (count > max) {
  13. max = count;
  14. }
  15. count = 0;
  16. }
  17. }
  18. if (count > max) {
  19. max = count;
  20. }
  21. System.out.println(max);
  22. }
  23. }
Success #stdin #stdout 0.08s 46808KB
stdin
Standard input is empty
stdout
5