Java : Changing a binary number bits 0's to 1's and 1's to 0's
<p>I was wondering how would you change a binary number and reverse the 1's and 0's?  I know how to change an integer number into binary already </p>

<pre><code>Example 1: 5 as a parameter would return 2
Steps: 5 as a binary is 101
          The complement is 010
          010 as an integer is 2
</code></pre>

<p>Code to change an integer to a binary number</p>

<pre><code>import java.io.*;
public class DecimalToBinary{
  public static void main(String args[]) throws IOException{
  BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  System.out.print("Enter the decimal value:");
  String hex = bf.readLine();

  int i = Integer.parseInt(hex);  


  String bynumber = Integer.toBinaryString(i);


  System.out.println("Binary: " + bynumber);
  }
} 
</code></pre>

<p>if anyone code please help, thank you!</p>
