The ? operator itself is nothing more than a shortcut for if. Lets take your example here:
String broker = args.Length > 0 ? args[0] : "localhost:5672"
The ? means if. Thus all left is the if part all right of ? is the then part. And the : separates the else part from the then part.
So to put it all together you could also write:
String broker;
if (args.Length > 0)
{
broker = args[0];
}
else
{
broker = "localhost:5672";
}
If you use it or not is mostly a matter of taste and how the code is better readable (if you need to do masses of short ifs just one after the next the ? can be better readable than the fully written method for example).