lundi 2 novembre 2020

Conditionals in java

public class Main {
    public static void main(String[] args) {
        String a = new String("Wow");
        String b = a;
        String c = new String("WoW");
        String d = new String("WoW");  
 boolean b1 = a == b;  
 boolean b2 = d.equals(b + "!");
 boolean b3 = !c.equals(a);
       
 if (b1 && b2 && b3) {
            System.out.println("Success!");
        }
    }
}

For the above code, when can boolean b2 = d.equals(b + "!"); be true. Pease help me with the changes to be made to Strings a, b, c or d(I should only change the first section of the code)

Aucun commentaire:

Enregistrer un commentaire