SafeAdder refactored to Java