?defined movingballs(int xd,int yd,int sizei)
and add the following code inside
[code]
x=Math.random()*xd;
y=Math.random()*yd;
[/code]

That is the reason why x,y are created randomly.

You can define something like 
movingballs(int xd,int yd,int xi,int yi,int sizei)
if you need to assign it to a new position (xi,yi)
and change the above code to
[code]
x=xi;
y=yi;
[/code]

Then you can initialize new particle with new xi,yi value set.