How can I make two objects of the same class bounce when colliding?

I made a bouncing ball code, and so far as the bouncing itself the code works perfectly. I then created a second ball, and it also does what it’s supposed to do. However, when I try to use an if condition to make the two balls bounce off one another as well as the edges, it doesn’t work. Either they don’t move or they just don’t collide, and go through each other. This code was made in processing. Can anyone help me make ball1 and ball2 collide?

Moving ball1;
Moving ball2;
void setup(){
  size(600,600);
  ball1 = new Moving();
  ball2 = new Moving();
}

void draw(){
  background(255);
  ball1.move();
  ball1.display();
  ball1.bounce();
  ball2.move();
  ball2.display();
  ball2.bounce();
  ball1.clash();
  ball2.clash();
}

class Moving {
  float speed = 7;
  float x = random(0, width);
  float y= random(0, height);
  float xdirection = 1;
  float ydirection = 1;
  float ball_size = 50;
  float radius = ball_size/2;
  Moving() {
  }
  void move() {
    x = x + (xdirection * speed);
    y = y + (ydirection* speed);
  }
  void display() {
    noStroke();
    fill(50, 0, 50);
    circle(x, y, ball_size);
  }
  void bounce() {
    if ((x >= width - radius) || (x <= radius)) {
      xdirection = xdirection * -1;
    }
    if ((y >= height - radius)|| (y<=radius)) {
      ydirection = ydirection * -1;
    }
  }
  void clash() {
    if ((ball1.y+radius == ball2.y+radius) && (ball1.x+radius == ball2.x+radius)) {
      ball1.ydirection = ball1.ydirection * -1;
      ball2.ydirection = ball2.ydirection * -1;
      ball1.xdirection = ball1.xdirection * -1;
      ball2.xdirection = ball2.xdirection * -1;
      x = x + (xdirection * speed);
      y = y + (ydirection* speed);
      if (ball1.x+radius == ball2.x+radius) {
        xdirection = xdirection * -1;
      }
    }
  }
}