Every time i restart a game of Pong i want the ball to appear in random position.
add(ball);
startX = rand.nextInt();
startY = rand.nextInt();
ball.setLocation(startX, startY);
This is the code I used but it makes my game freeze for one second every frame and I don't know the reason