Casting Boolean To Int
<p>I am going through a tutorial where so far it gives you the code below:</p>

<pre><code>boolean p, q;

    System.out.println("P\tQ\tAND\tOR\tXOR\tNOT");
    p = true; q = true;

    System.out.print(p + "\t" + q + "\t");
    System.out.print((p&amp;q) + "\t" + (p|q) + "\t");
    System.out.println((p^q) + "\t" + (!p));

    p = true; q = false;
    System.out.print(p + "\t" + q + "\t");
    System.out.print((p&amp;q) + "\t" + (p|q) + "\t");
    System.out.println((p^q) + "\t" + (!p));

    p = false; q = true;
    System.out.print(p + "\t" + q + "\t");
    System.out.print((p&amp;q) + "\t" + (p|q) + "\t");
    System.out.println((p^q) + "\t" + (!p));

    p = false; q = false;
    System.out.print(p + "\t" + q + "\t");
    System.out.print((p&amp;q) + "\t" + (p|q) + "\t");
    System.out.println((p^q) + "\t" + (!p));
</code></pre>

<p>The task is to modify the program so that it uses <code>1's</code> and <code>0's</code> instead of <code>true</code> and <code>false</code>.</p>

<p>Im not sure if this is ment to be done by Casting Incompatible Types but I think that is the way to go as that is the section before it.</p>

<p>Can anyone give some advice and explanation as to why it works? </p>
