Lolmister Lolmister - 4 months ago 17
Java Question

The opposite of instanceof

Is it possible to get the opposite of instanceof in java? I have tried code like this:

if( example !instanceof blarg)....


but it won't let me put the ! anywhere without an error, please help.

Answer

You have to negate the entire thing:

if(!(example instanceof blarg))