I need to generate random 4-byte length number in Java.
I came to this:
Random rnd = new Random();
int i = 0;
while((i=rnd.nextInt()) < 0x1000000){}
return i;
where 0x1000000 - is 3-byte value, and int is 4-byte according to JLS.
Are there any better solutions?
UPD: Yes, by "4-byte length" number I mean a 4-byte number with MSB (most significant byte)