You are correct, it is a java question.
You appear to be using an unsupported (in this forum) version of forge, I think 1.12? But then trying to use api that is from forge 1.19, e.g.
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; // <-- 1.12
import net.minecraftforge.eventbus.api.SubscribeEvent; // <-- 1.19
RegisterEvent was introduced in 1.19