Basic to intermediate array manipulation problems in Java