Monday, September 28, 2009

Java Riddle: instanceof and casting

Is it possible that the System.out.println line ever gets executed?

void brokenFunction(Object stringMaybe) {
if (stringMaybe instanceof String)
return;
String stringForSure = (String)stringMaybe;
System.out.println(stringForSure);
}

1 comment:

Andy said...

To me it looks like it will never print