I\'m attempting to create a method that checks an array for increasing elements. True should be returned if all the elements are in increasing order. I get an out-of-bounds
You can use Java 8's IntStream.
import java.util.stream.IntStream; public class Test { public static boolean isIncreasing(int[] a) { return IntStream.range(1, a.length).reduce(0, (acc, e) -> acc + (a[e - 1] <= a[e] ? 0 : 1)) == 0; } }