checking for variable type

Hey all
I was wondering if there was any way to have a constructor take a variable with an ambigious type and check its type via if statment. Here’s the pseudo of what I mean:

drawStuff(Graphics g, Type s){
c;
if(s.getType==Canvas){
c.setType(s)
}elseif(s.getType==Window){
c.setType(s)
}else{print.out(‘unrecognized type’)}
//draw stuff using c}

I guess I could pass in a string with ‘Canvas’ or ‘window’ and check that with the if statement but I as wondering if there was a built in way of doing this that is maybe a little more efficient.
Thanks in advance

You can pass an Object as an argument and use the ‘instanceof’ keyword like:

 if (obj instanceof Window) {
...

Ah great. Thanks for that, that was exactly what I was after

But this is kinda nasty, better make use of polymorphism.