I need help with collision detection in clone game

Consider an Arraylist of spaceships:

ArrayList example:

/**
 * ArrayList of Objects. 
 * 
 * Demonstrates the syntax for creating an ArrayList of custom objects. 
 */

//https://processing.org/reference/ArrayList.html

ArrayList<Particle> particles = new ArrayList<Particle>();
int count = 100;

void setup() 
  {
  size(500, 500);
  noStroke();
    
  for (int i = 0; i < count; i++) 
    {
    int xt = (int) random(width);
    int yt = (int) random(height);
    println(xt, yt);  
    particles.add(new Particle(xt, yt)); // adds particles    
    }
  }

void draw() 
  {
  background(0);
  
  push();
  noFill();
  strokeWeight(2);
  stroke(255, 0, 0);
  circle(mouseX, mouseY, 40);
  pop();
  
  //Loop backward to safely remove last particle
  for (int i = particles.size() - 1; i >= 0; i--) 
  
  //for (int i = 0; i<particles.size(); i++)     // Try this to see what happens!
    {
    Particle p = particles.get(i);
    
    // Remove if mouse is within 20 pixels inside circle
    if (dist(mouseX, mouseY, p.x, p.y) < 20) 
      {
      particles.remove(i);
      continue;  // exits loop once a particle is removed
      }
    
    p.update();
    p.display();
  }
}

class Particle 
  {
  float x, y;
  
  // Constructor
  Particle(int xTemp, int yTemp) 
    {
    x = xTemp;
    y = yTemp;
    }
  
  void update() 
    {
    // Future!  
    }
  
  void display() 
    {
    fill(255, 255, 0);
    circle(x, y, 10);
    }
  }

I shared the above to get you started.
ArrayLists of objects can be a challenge!

Other examples:

There may be more here:

:)