Code that attempts to protect against run-time casting errors is even more cumbersome:
Object o = stk.pop()
if (o instanceof String) {
String str = (String) o;
// blah blah blah
}
else {
// Oh no!
}
This is also only useful if a casting error has a response other than run-time explosions.
This page last modified on 24 January 2006.