import java.awt.Rectangle; public class RectangleExample { public static void main(String[] args) { // create a new Rectangle with x=10, y=20, width=100, height=50 Rectangle rect1 = new Rectangle(10, 20, 100, 50); // move the Rectangle to x=50 and y=70 rect1.setLocation(50, 70); // expand the Rectangle by 20 pixels in each direction rect1.grow(20, 20); // create a second Rectangle with x=30, y=40, width=80, height=60 Rectangle rect2 = new Rectangle(30, 40, 80, 60); // combine the two Rectangles into a new Rectangle that encompasses both Rectangle rect3 = rect1.union(rect2); // print out the information about the third Rectangle System.out.println("x = " + rect3.getX()); System.out.println("y = " + rect3.getY()); System.out.println("width = " + rect3.getWidth()); System.out.println("height = " + rect3.getHeight()); } }In this example, we create two Rectangle objects, manipulate them using the setLocation and grow methods, then combine them into a third Rectangle using the union method. Finally, we print out the information about the third Rectangle using methods such as getX, getY, getWidth, and getHeight. The Rectangle class is included in the java.awt package, which is part of the standard Java runtime library.