jeudi 30 août 2018

Java 8 if else alternative

Want to use Java 8 feature for my following code,

   boolean  var1 = true;
        boolean var2 = true;
        boolean var3 = var1 && var2;
        String result = var3 ? "variable3" : var2 ? "varible2" : "variable1";
        System.out.println(result);

Aucun commentaire:

Enregistrer un commentaire