Skip to content
Advertisement

Tag: ternary

Java – Check Not Null/Empty else assign default value

I am trying to simplify the following code. The basic steps that the code should carry out are as follows: Assign String a default value Run a method If the method returns a null/empty string leave the String as default If the method returns a valid string set the String to this result A Simple example would be: I have

Advertisement