Use the ternary operator:
name = ((city.getName() == null) ? "N/A" : city.getName());
I think you have the conditions backwards - if it's null, you want the value to be "N/A".
What if city is null? Your code *hits the bed in that case. I'd add another check:
name = ((city == null) || (city.getName() == null) ? "N/A" : city.getName());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…