Java Objects in Array - collision detection
问题 Let's say that I have code like this: private void actuallyDrawGraphics(Canvas canvas) { canvas.drawColor(Color.WHITE); for(Ball ball : balls){ canvas.drawBitmap(ballBitmap, -16 + (ball.x / 100f) * canvas.getWidth(), -16 + (ball.y / 100f) * canvas.getHeight(), paint ); } } Every ball is registered in an array. I need to make a collision (when one collides with the second) and everything goes well, until I have more balls, for example 10. It's not efficient to make a check like: ball 1 with 2,