How can I replace "true" and "false" in java? <p>i need change the values for boolean variables, for example:</p> <p>change this: boolean x = true; System.out.print(x); //console: true for this:</p> <pre><code>boolean x = true; System.out.print(x); //console: 1 </code></pre> <p>Sorry for my bad engish, thanks.</p> <p>This is my code </p> <pre><code>final boolean[] BOOLEAN_VALUES = new boolean [] {true,false}; for (boolean a : BOOLEAN_VALUES) { boolean x = negation(a); String chain = a+"\t"+x; chain.replaceAll("true", "1").replaceAll("false","0"); System.out.println(chain); } negation is a method: public static boolean negation(boolean a){ return !a; } </code></pre> <p>as you can see, i try using .replaceAll, but its not working, when i executed, this is the output:</p> <pre><code> a ¬a ---------------- true false false true </code></pre> <p>i really dont see my error.</p>