Where do these methods... live?

Hi, I have a question that may be really stupid but I just can’t quite wrap my head around what’s happening here.

When using methods like void draw() or void mousePressed()… are these part of an interface somewhere? I guess what I’m really asking… is why are we re-specifying the return type if the method already exists?

Thanks for any clarification here…

The base class for all sketches that use processing.core is PApplet

simplistic setup() and draw() are provided there and my understanding is that your sketch auto-magically subclasses this (IDE work) and you provide your own variation of those.

Adding on to @jay_m’s comment, Processing’s preprocessor takes code (in the Processing IDE) that looks like this…

void setup() {...}

void draw() {...}

…and produces a resulting Java class that looks something like this:

import processing.core.PApplet;

final class JavaVersion extends PApplet {

	public static void main(String[] args) {
		PApplet.main(JavaVersion.class);
	}

    @Override
    void setup() {...}
    
    @Override
    void draw() {...}

}