Java - Union and Intersection of two listsSuppose you have two lists, and you want Union and Intersection of those two…