0

Doubt about to verify one array in java

hi people i want to verify the elements of one array and show element at element if true or false in enside of one limited ex 10at100 this my function public static boolean entre10e100(int v[]) { for (int i = 0; i < v.length; i++) { if (v[i] > 10 || v[i] < 100) { if(i == v.length){ return true; } }else{ return false; } }

10th Jan 2018, 1:02 AM
Xremix27
Xremix27 - avatar
2 Antworten
0
add to the end of your method return true; although the program never gets there - it always gets to one of your return statements, but the compiler doesn't know this, so you get compile error if the lengthnof your array was 0, the program would never reach any return statement
10th Jan 2018, 3:36 PM
michal
0
and change if (i==v.length) to (i==v.length-1), because v.length -1 is the index of last element
10th Jan 2018, 3:38 PM
michal