I'm concerned about this construct:
String out = "Text " + (obj==null ? "" : obj.getStr()+" ") + "text continues.";
It works and all, but I think it's ugly. Maybe I'm just too picky..
Anyway, I'm asking, is there some nicer way to do this kind of stuff?
Or is this the generally accepted technique?
Well you can separate out the logic from the format, to start with:
String out = String.format("Text %stextcontinues",
obj == null ? "" : obj.getStr() + " ");
See more on this question at Stackoverflow