1.

What Is The Intersection And Union Methods?

Answer»

When your program uses Rectangle objects, you MAY NEED to determine the screen region that holds both objects or two Rectangle objects intersect, to find the intersection or the union of two rectangles, you can use the Rectangle class intersection and union methods. The intersection method returns the area where two Rectangle objects overlap. That is, the intersecting method return the area that two Rectangle objects have in common.

The union method, on the other hand, behaves differently than you might EXPECT. The union method returns the smallest rectangle that encloses two Rectangle objects, INSTEAD of returning just the area covered by both objects. This illustrates the behavior of the intersection and union methods.

When your program uses Rectangle objects, you may need to determine the screen region that holds both objects or two Rectangle objects intersect, to find the intersection or the union of two rectangles, you can use the Rectangle class intersection and union methods. The intersection method returns the area where two Rectangle objects overlap. That is, the intersecting method return the area that two Rectangle objects have in common.

The union method, on the other hand, behaves differently than you might expect. The union method returns the smallest rectangle that encloses two Rectangle objects, instead of returning just the area covered by both objects. This illustrates the behavior of the intersection and union methods.



Discussion

No Comment Found