dimanche 1 mai 2016

ternary operator IF else Java

Want to check why is it throwing error when i'm trying to concat a string with a ternary operator if else inside?

E.g

String varA = null;
String concatString = "something1" + "something2" + varA == null?"":varA.toUpperCase(); 

but when i'm trying to do this and it work:

String varA = null;
varA = varA == null?"":varA.toUpperCase();

Aucun commentaire:

Enregistrer un commentaire