maxSum, Java