Java Function To Check If Array Elements Are Consecutive