Java错误处理应怎样理解


Java异常处理应怎样理解
以下是我对Java异常处理的理解,希望大家给点意见。


1. If you can't handle an exception, don't catch it.

如果你不能好好对待她,不要骚扰她。

2. Catch an exception as close as possible to its source.

如果你想追求她,首先你要靠近她。

3. If you catch an exception, don't swallow it.

如果你已得到她,就要善待她。

4. Log an exception where you catch it, unless you plan to re-throw it.

如果你已得到她,就要好好了解她,除非你想抛弃她。

5. Never throw unchecked exceptions in your methods just because they clutter the method signature.

如果你已抛弃她,就要提醒别人继续追求她。

6. Preserve the stack trace when you re-throw the exception by wrapping the original exception in the new one.

如果你想抛弃一个全新的她,请尽量保留那个旧的她,以便别人还能够认出她。


java J2EE 程序开发

肛汁恋茎速湿 13 years, 1 month ago


好是好 能仔细解释一下吗


超爱大熊猫 answered 13 years, 1 month ago


15楼说的好 很简单的东西 弄的复杂了

坑爹呢这是 answered 13 years, 1 month ago


异常,是在运行时发生的错误。就说说在编译阶段是可用通过的,只有在程序启动的时候才能出现的错误。如果我们学习了异常,就可以对我们程序中将要出现的错误做一个异常处理,给这个异常一个只有我们才有的编号,用户对这个编号是不理解什么意思的。但是对我们程序员来说:这个编号是代表了特殊的含义,让我们更快的找到错误出现的地方。

ovovovo answered 13 years, 1 month ago


牛逼

taylor answered 13 years, 1 month ago


呵呵,好想法
顶一个!

windzcc answered 13 years, 1 month ago


如果你想追求她,首先你要靠近她。 应该怎么理解?

请叫我Am answered 13 years, 1 month ago


如果能再给点解释就更好了!

Macross answered 13 years, 1 month ago


有创意

N.sweet answered 13 years, 1 month ago


哈哈。不错。

neKo. answered 13 years, 1 month ago


up~

2P腋巫女 answered 13 years, 1 month ago


很有才

DECO❀27 answered 13 years, 1 month ago


  Java code

  看得有点晕

路西安卡尔兹 answered 13 years, 1 month ago


不错

科学贵公子 answered 13 years, 1 month ago

Your Answer