I was looking for the differences between Java platforms and i noticed that J2ME does not have exception handlers.
Wh开发者_高级运维at makes try-catch so heavy that Sun did not include them in Java ME?
If you're talking about exception handlers such as set by Thread.setUncaughtExceptionHandler
, then the reason is simple:
All current Java ME versions are based on pretty old Java SE versions (1.3, I think, but don't quote me on that exact version). And that Java SE version simply didn't have that feature, so they didn't "remove" anything in Java ME in this instance.
Note, also, that those handlers are easily emulated by starting your Thread
with a Runnable
that catches all exceptions and handles them as desired, so they are not an irreplaceable API element.
精彩评论