i was coding a program for school in Java with Eclipse and i got a problem with the output, the code is the following:
public class Main {
public static boolean[] cercaK(int k , String[] a){
boolean b[] = new boolean[a.length];
int conta = 0;
for(int i = 0; i < a.length; i++){
b[i] = false;
int j = 0;
while(j < a[i].length()-1 && !b[i]){
if(a[i].charAt(j)==a[i].charAt(j+1))
conta++;
else
conta = 0;
if (conta == k)
b[i] = true;
j++;
}
}
return b;
}
public static void main(String[] args) {
String[] a = {"accesso","bbtcrryy","ggg"};
int k = 2;
if (k<=0)
System.out.println("Errore!");
boolean[] b = cercaK(k,a);
for(int i = 0; i < b.length; i++)
System.out.print(b);
}
}
And the output is really strange:
[Z@106d69c[Z@106d69c[Z@106d69c
I can't understand from where these strings come from. Can anyone please help me? Thanks!
EDIT: I found the error,
for(int i = 0; i < b.length; i++)
System.out.print(b[i]);