A common bug in published code
For non-Java heads, (int) Math.random() generates a random double from [0,1) which is then cast as an integer (which means that it is always truncated to 0).They probably wanted something like (int) (Math.random()*2) which will give you 0 half the time or 1 half the time.Although it is still a really inefficient way to generate 1-bit of entropy  (but sometimes it just isn't worth the trouble to instantiate a Random object, so I guess I could look past that ...).