lundi 14 mai 2018

How can I simplify this if-else into one statement?

I have below code. I tried a lot but how can I simplify this to one line(without if-else):

public static void main(String[] args) {
        boolean result;
        boolean a = false;
        boolean b = false;
        boolean isEmpty = false;
        if (a) {
            result = isEmpty && !b;
            System.out.println("if  " + (isEmpty && !b));
        } else {
            System.out.println("else    " + !b);
            result = !b;
        }

        System.out.println(result);


    }

Aucun commentaire:

Enregistrer un commentaire