You probably want to use "instanceof" instead of "==".