hi,
i want to return true if previous value in an arry is >= current vallues and false if <=..
int d= scores[i+1]; this line is throwing the arrayindexoutof bonds error pls help.
Given an array of scores, return true if each score is equal or greater than the one before. The array will be length 2 or more.
scoresIncreasin g({1, 3, 4}) → true
scoresIncreasin g({1, 3, 2}) → false
scoresIncreasin g({1, 1, 4}) → true
public boolean scoresIncreasin g(int[] scores) {
int a= scores.length;
boolean b = false;
for (int i=0; i<=a;i++){
int c =scores[i];
int d= scores[i+1];
if (a>=2 && c<=d) b= true;
}
return b;
}
i want to return true if previous value in an arry is >= current vallues and false if <=..
int d= scores[i+1]; this line is throwing the arrayindexoutof bonds error pls help.
Given an array of scores, return true if each score is equal or greater than the one before. The array will be length 2 or more.
scoresIncreasin g({1, 3, 4}) → true
scoresIncreasin g({1, 3, 2}) → false
scoresIncreasin g({1, 1, 4}) → true
public boolean scoresIncreasin g(int[] scores) {
int a= scores.length;
boolean b = false;
for (int i=0; i<=a;i++){
int c =scores[i];
int d= scores[i+1];
if (a>=2 && c<=d) b= true;
}
return b;
}
Comment