Rectangle rect = new Rectangle(50, 50, 100, 100);
Point point = new Point(75, 75); if(rect.contains(point)) { // Point is inside the rectangle }
Rectangle rect1 = new Rectangle(50, 50, 100, 100); Rectangle rect2 = new Rectangle(75, 75, 100, 100); Rectangle intersection = rect1.intersection(rect2);This code creates two Rectangle objects, one with a size of 100x100 pixels starting at (50,50) and the other with a size of 100x100 pixels starting at (75,75). The intersection of the two rectangles is then stored in the intersection variable. The resulting rectangle would be 75x75 pixels starting at (75,75). The package library for java.awt.Rectangle is the java.awt package.