Rectangle rect = new Rectangle(10, 20, 30, 40); double minX = rect.getMinX(); System.out.println("The x-coordinate of the left edge is: " + minX);
Rectangle rect1 = new Rectangle(0, 0, 50, 50); Rectangle rect2 = new Rectangle(25, 25, 50, 50); if (rect2.getMinX() < rect1.getMinX()) { System.out.println("Rect2 is to the left of Rect1."); } else { System.out.println("Rect2 is not to the left of Rect1."); }This code creates two rectangles, one with x = 0, y = 0, width = 50, and height = 50, and the other with x = 25, y = 25, width = 50, and height = 50. It then compares the x-coordinate of the left edge of each rectangle using `getMinX()`, and prints a message indicating which one is to the left. The `java.awt.Rectangle` class is part of the Java Standard Library, which is included in the `java.*` package.