You are checking collision between n particles
with loop like
for(int i=0;i for(j=0;j }
}
In the above case, collision between particles might be processed twice.
You can change the loop to
for(int i=0;i for(j=0;j  if(i!=j){// particle can not collide with itself
  }
}

And I did not fully understand what do you mean by
"somethimes the balls don't colide right  Huh"!
You only tell me you think there is something wrong, But I did not know what is wrong!


}