Cannot Convert From Object to <myClass>
              in 
             Programming Questions 
              •  
              3 months ago    
            
 
           
             That's the error I'm getting with this code and I don't understand why...
            
            
This is just a test code for the exact same problem that I'm facing in another project I'm working on. I mean, I declared an array of type G and now simply want to append objects of the same type to it. So why isn't that working?
            
            
 
            
           This is just a test code for the exact same problem that I'm facing in another project I'm working on. I mean, I declared an array of type G and now simply want to append objects of the same type to it. So why isn't that working?
- G[] Gog={};
 - void setup(){
 - }
 - void draw(){
 - }
 - void mouseReleased(){
 - G fog=new G(random(4,10),random(4,10));
 - println(fog.k);
 - Gog=append(Gog,fog);
 - for(int i=0;i<Gog.length;i++){
 - print(Gog[i].k+" ");
 - }
 - println();
 - }
 - class G{
 - float k;
 - float s;
 - G(float k,float s){
 - this.k=k; this.s=s;
 - }
 - }
 
 
              
              1  
            
 
            