I know there is a way for writing a Java if statement in short form.
if
if (city.getName() != null) { name = city.getName(); } else { name=
You can use ternary operator in java.
Syntax:
Condition ? Block 1 : Block 2
So in your code you can do like this,
name = ((city.getName() == null) ? "N/A" : city.getName());
For more info you can refer this resource.