You seem to want to create a random array of bytes. But what you are currently doing is generating a random array of 0 and 1 bytes (not bits). All of your bytes (=8 bits) are either 00000000 or 00000001. What you really want is a byte in the range 0-255. You should use Random.nextBytes(byte[] genes) to create your genes.
Generates random bytes and places them into a user-supplied byte array. The number of random bytes produced is equal to the length of the byte array.)
Then you want to convert this back into a decimal. However, as soon as you have more than 4 bytes, the values will no longer fit into a 32-bit (=4 byte) integer. If you have more than 8 bytes, they won't fit into a 64-bit integer etc.
For conversion, I'd use the BigInteger class. It takes care of the conversion for you, so you don't have to deal with endianness.
So, assuming you want a random gene of 64 bits, you do this as follows:
public static void main( String args[] ){
// create random object
Random r = new Random();
int numBits = 64;
int numBytes = numBits/8;
// create the byte array
byte[] genes = new byte[numBytes];
//fill it
r.nextBytes(genes);
//print it
System.out.println("byte array: " + genes);
//now convert it to a 64-bit long using BigInteger
long l = new BigInteger(bytes).longValue();
//print it
System.out.println("long: " + l);
}
Of course, you could also generate a random long value directly, by using:
Random r = new Random();
long longGenes = r.nextLong();
And convert that to a byte array if you really need one:
byte[] genes = new BigInteger(longGenes).toByteArray();