Find the longest sequence of increasing numbers in an array
The thing I dislike the most is the check I make for the last element in order to avoid ArrayIndexOutOfBounds exception.


So let's avoid that check. Let's structure our loop such that we're back-comparing. That is, instead of comparing index i to index i+1, we compare index i to index i-1. That way, if we start at 1, we'll always have a valid comparison - since otherwise our loop invariant would've triggered:

for (int i = 1; i &lt; vals.length; ++i) {
    if (vals[i] &gt; vals[i-1]) {
        // continuing this sequence
    }
    else {
        // start a new sequence, of length 1, from i
    }
}


No further checks against vals.length are necessary, once we handle the empty case. The rest of the algorithm involves just keeping track of a current running sequence and the best sequence so far, which you could do with a local ArrayList&lt;Integer&gt; but better to just do with a couple ints.