rand ( ) function will generate odd or even number with equal probability . If rand ( ) generates odd number , the function will return 1 else it will return 0.
Random rand = new Random ( ) ; return ( rand . nextInt ( ) & 1 ) ; }