Except Java doesn’t actually return a result object that can be assigned to a variable by default.
(For other things, I agree that sum types are cool, and fortunately are supported in Java through sealed classes)