jeudi 1 septembre 2016

Java. if statement inside String as function argument

Is there a way to include a simple if statement inside a Java String passed as argument to a function, like the following example

int TotalFiles = 3;
JOptionPane.showMessageDialog(frame, 
                     "Created " + TotalFiles + " file" + (if(TotalFiles>1){"s"}) + ".");

Aucun commentaire:

Enregistrer un commentaire