title: Generate random binay String of fixed length in Java
body: <p>I have the code below and all I want is to create a random binary of fixed length (eg 4 bits). I want 4 bits to be used. I want it like that because after that I need to store it in a byte array (eg byte[][] myArray = new byte [2][0])</p>
  
  <pre><code>public String Random(){
      Random rg = new Random();
      int n = rg.nextInt();
      return Integer.toBinaryString(n);   
  }
  </code></pre>