Java,手动throw exception和error有什么区别?
怪我咯
怪我咯 2017-04-18 09:48:45
0
2
361

示例代码如下

                if (input.length != 2) {
                    logger.error("The input for execute " + component.toString() + " is not right!");
                    throw new Exception("hehehe");
                }

                if (input.length != 2) {
                    logger.error("The input for execute " + component.toString() + " is not right!");
                    throw new Error("hehehe");
                }
怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
小葫芦

Exception:

1. Can be controlled (checked) or uncontrollable (unchecked).
2. Indicates an error caused by the programmer.
3. Should be handled at the application level.

Error:

1. Always unchecked.
2. Often used to indicate 系统错误底层资源 errors.
3. Whenever possible, it should be caught at the system level.

阿神

I remember it seems that it will never be used in your programthrow error

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!