I have a method, which keeps giving me compilation errors. At first I had a return statement for the if and else statements. I couldn't get it to work with 2 return statements, so I changed it into what I have now.
The error message now says that it can't find variable 'x'. I put the return statement inside the previous set of {}, and that still never worked. So I'm not sure if I have to completely redesign my method, or if this is a simple fix.
public static boolean equalN(int [] holdN){
for(int i=0;i<=holdN.length;i++){
int k=1;
boolean x;
if(holdN[i]==holdN[k]){
k++;
x=true;
}
else{
x=false;
}
}
return x;
}
Aucun commentaire:
Enregistrer un commentaire