Use Java to sort through arrays and filter based on certain criteria