vendredi 5 juin 2020

Checking a boolean in Java

I'm relatively new to Java and I was messing with this function, and I wanted to ask why it prints out "Fail" and not "Success".

import java.util.*;
class Test {  
    public static void main(String args[]) {  
        boolean x = false;
        if (x = false) {
            System.out.println("Success");
        } else {
            System.out.println("Fail");
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire