When building applications in Java that deal with two-dimensional data, one of the most common needs is to represent and…