I was wondering if it was possible to have Intellij code inspection recognise "instanceof" and mark it as correct. The code i provided in the picture works, I just want to stop Intellij from drawing the red line
You can ignore and supress inspections for Intellij from the Settings menu.
Settings/Preferences dialog (Ctrl+Alt+S), select Editor | Inspections.
Or you can supress/disable inspections by selecting the statement and pressing Alt + Enter
and then pressing Disable inspection
(if this is provided) . You can read the official documentation from Intellij.
You can find the full list of Java inspections for Intellij here.