https://processing.org/reference/endShape_.html
Everything between beginShape() and endShape() is combined together. endShape(CLOSE) will close the shape by drawing line from the first point to the last point. Fill color is set with fill()-function before beginShape().

Doesn’t this just put a straight line through the first and last point?

My question is when you have 2 separate curves with the same starting and ending vertices. How do you fill in the space between them? So essentially connect the first and last vertex with another curve instead of a straight line.

It creates an enclosure that is filled. If end and start point are side by side or even the same it’s still enclosed shape and gets filled. You don’t have to use keyword ‘CLOSE’, but you can to ensure that shape is a enclosure.