Using Java classes
              in 
             Programming Questions 
              •  
              9 months ago    
            
 
           
             Hi there,
            
             
            
            
             
            
            
             
            
            
             
            
            
             
            
            
              
           
 
            
           
             I'm going through Dan Shiffman's book "The nature of code" at the moment.
            
            
             In one of the "random number" examples he mentions that we can make use of a class know as 
             Random which is part of the default Java libraries imported into processing. (
             http://docs.oracle.com/javase/6/docs/api/java/util/Random.html)
            
            
             However when I use this I get the error "Cannot find a class or type named Random". How would I get this to work?
            
            
             Here is the example.
            
            - Random generator;
- void setup(){
- size(640,360);
- generator = new Random();
- }
- void draw(){
- float num = (float)generator.nextGaussian();
- float sd = 60;
- float mean = 320;
- float x = sd * num + mean;
- noStroke();
- fill(255,10);
- ellipse(x,180,16,16);
- }
 
              
              1  
            
 
            
 
 
           
 
             
              
              
             