If I understand correctly, you can use the ternary opperator:
System.out.println("My string is: " + ((string == null) ? "" : string));
In case you are not familiar with it, it reads "Is string null? If it is, then 'return' en empty string, else 'return' string". I say 'return' because you can consider ((string == null) ? "" : string)
as a function that returns a String
.
You can replace the empty string with any other String
of course.