The function nextGaussian() does not exist

Hi, I was trying to use the function nextGaussian() in class Random and this problem came up.

Then, I tried to add "import java.util.Random;"; it says "The import java.util.Random conflicts with a type defined in the same file."

Finally I used "final Random generator = new Random();" instead; it doesn't seem help at all.

My processing version is 3.2.1

The code shows as below:

Random generator;

void setup(){
  size(640,360);
  generator = new Random();
}

void draw(){
  float x = (float) generator.nextGaussian();
}

Answers

  • edited October 2016

    Is your sketch named Random? If it is change it to something else.

    Using the final keyword will have absolutely no effect in this situation.

  • you can always use the fully qualified class name to avoid this

    drop the import

    java.util.Random generator;
    ...
    generator = new java.util.Random(); 
    
Sign In or Register to comment.