You should do this:
public Area getRectanglesColisionArea(Rectangle rect1, Rectangle rect2){
Area shape1 = new Area(rect1);
Area shape2 = new Area(rect2);
return shape1.intersect(shape2);
}
Returning area shape is the
To call the function just:
Rectangle rect1 = new Rectangle(20, 300, 400, 160);
Rectangle rect2 = new Rectangle(150, 60, 230, 450);
Area result = getRectanglesColisionArea(rect1,rect2);
The Area result is the shape of the intersection, from there you can get the intersection points:
Rectangle inters = result.getBounds();
Double x1=inters.getX();
Double y1=inters.getY();
Double x2=inters.getX()+inters.getWidth();
Double y2=inters.getY()+inters.getHeight();