Review implementation of boolean triple Let a,b,c be a boolean value. I need to print all values of expression a &amp;&amp; b &amp;&amp; c. I'm writing the class

public class BooleanTriple{
    private boolean a,b,c;
    public BooleanTriple(boolean a, boolean b, boolean c){ this.a =a; this.b=b; this.c=c;}

    /**
    *Increments the value of triple with lexicographical ordering
    */
    public void incr(){
        if (!a) a=true;
        else if(!b){
            a= false;
            b= true;
        else if (!c){
            a= false;        
            b= false;
            c=true;  
        }
    }
    public boolean logProduct(){ return a &amp;&amp; b &amp;&amp; c;}
}


And Main class:

public class Main{
    BooleanTriple bTriple = new BooleanTriple(false,false,false);
    public static void main(String[] args){
        for (int i=0; i&lt;8; i++){
            System.out.println(bTriple.logProduct());
            bTriple.incr();
        }
    }
}


But i think, that it's bad implementation. Can you correct me?
if I quite understand your problem, to do a proper incr() method I would do so :

public class BooleanTriple {
    private boolean a,b,c;
    private int i;
    public BooleanTriple(boolean a, boolean b, boolean c){
        this.a =a; this.b=b; this.c=c;
        this.i = (a ? 1 : 0)*4+(b ? 1 : 0)*2+(c ? 1 : 0)*1;  // not sure if this compile, but the idea is here
    }

    public void incr(){
        i = (i + 1) % 8;
        a = (i &amp; 0x4) != 0;
        b = (i &amp; 0x2) != 0;
        c = (i &amp; 0x1) != 0;
    }
    public boolean logProduct(){ return a &amp;&amp; b &amp;&amp; c;}
}


With i going from 0 (000 binary) to 7 (111 binary) you have all the possible values for a, b and c