public static boolean checkBoth(int[] vals) {
boolean gt15 = false;
boolean lt10 = false;
for (int i = 0; i < vals.length; i++)
if (vals[i] > 15)
gt15 = true;
for (int i = 0; i < vals.length; i++)
if (vals[i] < 10)
lt10 = true;
return gt15 && lt10;
}
Function Call | Return Value | |||
---|---|---|---|---|
checkBoth(new int[]{16, 4, 5}) | → | |||
checkBoth(new int[]{4, 6, 8}) | → | |||
checkBoth(new int[]{5, 15, 10}) | → | |||
checkBoth(new int[]{6, 5, 9}) | → | |||
checkBoth(new int[]{16, 5, 9}) | → | |||
checkBoth(new int[]{16, 15, 19}) | → |
Experiment with this code on Gitpod.io