import java.awt.Rectangle; public class RectangleExample { public static void main(String[] args) { Rectangle rect = new Rectangle(10, 20, 30, 40); double centerY = rect.getCenterY(); System.out.println("Center Y coordinate: " + centerY); } }In this example, we create a Rectangle object with x=10, y=20, width=30, and height=40. Then, we call the getCenterY() method on the rect object to get the Y coordinate of its center. The result is then printed to the console. This code example shows how to use the getCenterY() method in java.awt.Rectangle to find the center Y coordinate of a rectangle. The package library used in this example is java.awt.