It is always difficult and take time to find out the bug, especially you are working with another language.

Did you change the setting in the loop for your code?
Did you make sure all the particles are not overlap with each other in the initial state?
If you can run  your code step by step, you might be able to find out bugs in your code.
I was assuming the distance moved between each time step is smaller than the size of the particle.
It might be your time step is too large or the velocity is too big. In that case, try to use a smaller time step.

The original source code for this java applet is attached.