LengthCalculation - Java