Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Created November 11, 2013 17:12
Show Gist options
  • Select an option

  • Save pjc0247/7416728 to your computer and use it in GitHub Desktop.

Select an option

Save pjc0247/7416728 to your computer and use it in GitHub Desktop.
import java.lang.reflect.*;
import java.util.Random;
class Test{
static {
try {
Field field = Math.class.getDeclaredField("randomNumberGenerator");
field.setAccessible(true);
field.set(null, new Random(){
@Override
public double nextDouble(){
return 1;
}
});
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args){
System.out.println( java.lang.Math.random() );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment