I am trying to cast a object during an if - else statement as follows:
if(sourceSystem.equalsIgnoreCase("Src")) {
MO object = (MO) transformer.create(message,sourceSystem,flowName);
} else {
UO object = (URO) transformer.create(message,sourceSystem,flowName);
}
However it cannot be accessed outside of these?
validator.validate(object);
cannot be resolved to a variable. But surely the object is being created an assigned within the if-else statement. The object will always be created, therefore why is the compiler telling me it cannot be resolved to a variable. Yes I get local and global vairables however if I need to access a common method between UO and MO.