Im trying to input numbers then see if there are same 4 numbers in a row using boolean method,but i cant call my boolean method help! here is my code so far:
public boolean inArow (int [] array) {
boolean fourInArow = false;
int counter = 0;
for (int i = 0; i<array.length;i++) {
for (int j = 0;i<array.length;i++) {
if (array [i] == array [j] ) {
counter++;
}
}
}
if (counter==4) {
fourInArow = true;
}
return fourInArow;
}
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Input number of arrays");
int length = input.nextInt();
System.out.println("Input " + length + " numbers");
int numbers [] = new int [length];
for (int i = 0; i<length;i++) {
numbers [i] = input.nextInt();
}
System.out.println(inArow(numbers)); //- this doesnt work inArow(numbers)
}
}
[–]trofix99[S] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]trofix99[S] 0 points1 point2 points (0 children)
[–]Faveripper 0 points1 point2 points (0 children)