Is there any way to add default condition into if else loop. If X is true then operation1 executes else operation2. If X is null then default operation gets executed.
if (x)
{ operation1 }
else
{ operation2 }
default
{default operation}
CodePudding user response:
No default null-condition is provided in Java/Groovy as a null
is not treated as default case.
You have to check against the null
yourself:
if (null)
{ operationNull }
else if (x)
{ operation1 }
else
{ operation2 }