Java¿ª·¢¿ò¼ÜÖ®
ÔÎĵØÖ·£ºhttp://hi.baidu.com/lin_zy/blog/item/bf14d21f6bb12ff6e1fe0bf1.html
¸ÅÄî
ʲôÊÇÒì³££¿
Òì³££¨exception£©Ó¦¸ÃÊÇÒ쳣ʼþ£¨exceptional event£©µÄËõд¡£
Òì³£¶¨Ò壺Òì³£ÊÇÒ»¸öÔÚ³ÌÐòÖ´ÐÐÆڼ䷢ÉúµÄʼþ£¬ËüÖжÏÕýÔÚÖ´ÐеijÌÐòµÄÕý³£µÄÖ¸ÁîÁ÷¡£
µ±ÔÚÒ»¸ö·½·¨Öз¢Éú´íÎóµÄʱºò£¬Õâ¸ö·½·¨´´½¨Ò»¸ö¶ÔÏ󣬲¢ÇÒ°ÑËü´«µÝ¸øÔËÐÐʱϵͳ¡£Õâ¸ö¶ÔÏó±»½Ð×öÒì³£¶ÔÏó£¬Ëü°üº¬ÁËÓйشíÎóµÄÐÅÏ¢£¬ÕâЩÐÅÏ¢°üÀ¨´íÎóµÄÀàÐͺÍÔÚ³ÌÐò·¢Éú´íÎóʱµÄ״̬¡£´´½¨Ò»¸ö´íÎó¶ÔÏó²¢°ÑËü´«µÝ¸øÔËÐÐʱϵͳ±»½Ð×öÅ׳öÒì³£¡£
Ò»¸ö·½·¨Å׳öÒì³£ºó£¬ÔËÐÐʱϵͳ¾Í»áÊÔ×ŲéÕÒһЩ·½·¨À´´¦ÀíËü¡£ÕâЩ´¦ÀíÒì³£µÄ¿ÉÄܵķ½·¨µÄ¼¯ºÏÊDZ»ÕûÀíÔÚÒ»ÆðµÄ·½·¨ÁÐ±í£¬ÕâЩ·½·¨Äܹ»±»·¢Éú´íÎóµÄ·½·¨µ÷Óá£Õâ¸ö·½·¨ÁÐ±í±»½Ð×ö¶ÑÕ»µ÷Óã¨call¡¡stack£©
ÔËÐÐʱϵͳËÑÑ°°üº¬Äܹ»´¦ÀíÒì³£µÄ´úÂë¿éµÄ·½·¨ËùÇëÇóµÄ¶ÑÕ»¡£Õâ¸ö´úÂë¿é½Ð×öÒì³£´¦ÀíÆ÷£¬ËÑÑ°Ê×ÏÈ´Ó·¢ÉúµÄ·½·¨¿ªÊ¼£¬È»ºóÒÀ´Î°´×ŵ÷Ó÷½·¨µÄµ¹Ðò¼ìË÷µ÷ÓöÑÕ»¡£µ±ÕÒµ½Ò»¸öÏàÓ¦µÄ´¦ÀíÆ÷ʱ£¬ÔËÐÐʱϵͳ¾Í°ÑÒì³£´«µÝ¸øÕâ¸ö´¦ÀíÆ÷¡£Ò»¸öÒì³£´¦ÀíÆ÷ÒªÊʵ±µØ¿¼ÂËÅ׳öµÄÒì³£¶ÔÏóµÄÀàÐͺÍÒì³£´¦ÀíÆ÷Ëù´¦ÀíµÄÒì³£µÄÀàÐÍÊÇ·ñÆ¥Åä¡£Òì³£±»²¶»ñÒÔºó£¬Òì³£´¦ÀíÆ÷¹Ø±Õ¡£Èç¹ûÔËÐÐʱϵͳËÑÑ°ÁËÕâ¸ö·½·¨µÄËùÓеĵ÷ÓöÑÕ»£¬¶øûÓÐÕÒµ½ÏàÓ¦µÄÒì³£´¦ÀíÆ÷¡£
ÔõôÉè¼ÆÒì³£¿ò¼Ü
ÈκεÄÒì³£¶¼ÊÇThrowableÀࣨΪºÎ²»Êǽӿڣ¿£¿£©£¬²¢ÇÒÔÚËü֮ϰüº¬Á½¸ö×ÖÀàError / Exception£¬¶øError½öÔÚµ±ÔÚJavaÐéÄâ»úÖз¢Éú¶¯Ì¬Á¬½Óʧ°Ü»òÆäËüµÄ¶¨Î»Ê§°ÜµÄʱºò£¬JavaÐéÄâ»úÅ׳öÒ»¸öError¶ÔÏó¡£µäÐ͵ļòÒ׳ÌÐò²»²¶»ñ»òÅ׳öErrors¶ÔÏó£¬Äã¿ÉÄÜÓÀÔ¶²»»áÓöµ½ÐèҪʵÀý»¯ErrorµÄÓ¦Óã¬ÄǾÍÈÃÎÒÃǹØÐÄÒ»ÏÂException
ExceptionÖбȽÏÖØÒªµÄ¾ÍÊÇRuntimeException£ÔËÐÐʱÒì³££¨µ±È»Õâ¸öÃû×ÖÊÇ´æÔÚÕùÒéµÄ£¬ÒòΪÈκεÄÒì³£¶¼Ö»»á·¢ÉúÔÚÔËÐÐʱ£©£¬ÎªÊ²Ã´ËµÕâ¸öÀàʱºÜÖØÒªµÄÄØ£¿ÒòΪËüÖ±½Ó¹Øϵµ½ÄãµÄÒì³£¿ò¼ÜµÄÉè¼Æ£¬×Ðϸ¿´RuntimeException
A method is not required to declare in its throws clause any subclasses of RuntimeException that might be thrown during the execution of the method but not caught.
£¿ÉÄÜÔÚÖ´Ðз½·¨ÆÚ¼äÅ׳öµ«Î´±»²¶»ñµÄ RuntimeException µÄÈκÎ×ÓÀ඼ÎÞÐèÔÚ throws ×Ó¾äÖнøÐÐÉùÃ÷¡£
Ò²¾ÍÊÇ˵ÄãµÄÓ¦ÓÃÓ¦¸Ã²»È¥“¹ØÐÄ”£¨Ëµ²»¹ØÐÄÊDz»·þÔðÈεģ¬µ«Ö»ÊÇÄã²»Ó¦¸ÃÊÔͼʵÀý»¯ËüµÄ×ÖÀࣩRuntimeException£¬¾ÍÈçͬÄã²»Ó¦¸Ã¹ØÐÄErrorµÄ²úÉ
Ïà¹ØÎĵµ£º
1 JDK5.0°üÀ¨µÄµ÷ÊÔ¹¤¾ß
ÎÒÃÇÔÚÕâÀï¶ÔJDK5.0µÄµ÷ÊÔ¹¤¾ß×ö´óÖµĸÅÄîÐԵĽéÉÜ£¬È»ºóÏ£Íûͨ¹ý½éÉÜÎÒ×Ô¼ºÔÚʵ¼Ê¹¤×÷ÖÐʹÓÃÕâЩ¹¤¾ß½â¾öÎÊÌâµÄʵÀýÀ´Èôó¼Ò¶ÔÕâЩ¹¤¾ßÓиüÉîÈëµÄÁ˽⡣
¡¡JDK5.0ÀïÃæ¼ÓÈëÁËjstack, jconsole, jinfo, jmap, jdb, jstat, jps, ÏÂÃæ¶ÔÕâЩ¹¤¾ß×ö¼òµ¥½éÉÜ£º
¡¡jstack -- Èç¹ûjava³Ì ......
×°ÊÎÆ÷ģʽÖ÷ÒªÓ¦ÓÃÓÚÕâÑùÒ»ÖÖ³¡ºÏ£¬µ±ÄãÒѾÓÐÁËÒ»¸öÄ¿±êÀ࣬²¢ÇÒËüÊÇÒ»¸ö½Ó¿ÚµÄʵÏÖÀ࣬ÔÚ¶Ô¸ÃÀàʹÓõĺóÆÚ·¢ÏÖÐèÒª¶ÔÏàÓ¦½Ó¿Ú³ÌÐòµÄÇ°ºó×ö¸ü¶àµÄ´¦Àí£¬ÕâЩ´¦ÀíÊDZ仯µÄ£¬²»¹Ì¶¨µÄ£¬µ«ÊÇÓв»ÄÜÈ¥ÐÞ¸ÄÕâ¸öÄ¿±êÀ࣬ÕâʱÎÒÃǾͿÉÒÔʹÓÃÕâ¸ö×°ÊÎÆ÷ģʽ£º
±ÈÈ磬ÎÒÃÇÒѾÓÐÒ»¸ö¸¶¿îµÄ·½·¨ payMoney(long count) £¬Õâ¸ö·½·¨Ö» ......
2009Äê1Ô£¬Ä³Èí¼þ¹«Ë¾Ò»ÔòÄêнʮÍòÕÐƸJAVA¸ß¼¶Èí¼þ¹¤³ÌʦµÄ¹ã¸æÎüÒýÁËÖÚ¶àýÌåºÍIT´ÓÒµÈËÔ±µÄÄ¿¹â£¬´ó¼ÒÖÃÒɵijýÁËÆľßÎüÒýÁ¦µÄÄêн֮Í⣬¸ü¶àµÄÊǶԸÃÆóÒµÔ¸ÒâƸÇë“ÓÐÄÜÁ¦µÄÓ¦½ì±ÏÒµÉú”¸Ðµ½À§»ó¡£ÔÚ´ó¶àÊýÆóÒµ¶¼Ç¿µ÷¹¤×÷¾ÑéµÄʱºò£¬¸ÃÆóҵΪʲôԸÒâ¸ß¶îƸÇëÓ¦½ì±ÏÒµÉúÄØ£¿¸ÃÆóÒµ¸ºÔðÈ˵ÄÒ»¾ä¿´ËƼòµ¥µÄ&ld ......
1.½éÉÜ
1£©DOM£¨JAXP Crimson½âÎöÆ÷£©
DOMÊÇÓÃÓëƽ̨ºÍÓïÑÔÎ޹صķ½Ê½±íʾXMLÎĵµµÄ¹Ù·½W3C±ê×¼¡£DOMÊÇÒÔ²ã´Î½á¹¹×éÖ¯µÄ½Úµã»òÐÅϢƬ¶ÏµÄ¼¯ºÏ¡£Õâ¸ö²ã´Î½á¹¹ÔÊÐí¿ª·¢ÈËÔ±ÔÚÊ÷ÖÐÑ°ÕÒÌض¨ÐÅÏ¢¡£·ÖÎö¸Ã½á¹¹Í¨³£ÐèÒª¼ÓÔØÕû¸öÎĵµºÍ¹¹Ôì²ã´Î½á¹¹£¬È»ºó²ÅÄÜ×öÈκι¤×÷¡£ÓÉÓÚËüÊÇ»ùÓ ......
public£¨¹«¹²·ÃÎÊ¿ØÖÆ£©£º¿ÉÒÔ±»ËùÓÐÀà·ÃÎÊ¡£
protected£¨±£»¤·ÃÎÊ¿ØÖÆ£©£º¿ÉÒÔ±»Õâ¸öÀà±¾Éí¡¢ËüµÄ×ÓÀࣨ°üÀ¨Í¬Ò»¸ö°üÖÐÒÔ¼°²»Í¬°üÖеÄ×ÓÀࣩºÍͬһ¸ö°üÖеÄËùÓÐÆäËûÀà·ÃÎÊ¡£
default£¨ÓѺ÷ÃÎÊ¿ØÖÆ£©£º¿ÉÒÔ±»Õâ¸öÀà±¾ÉíºÍͬһ¸ö°üÖеÄÆäËûÀàËù·ÃÎÊ¡£
private£¨Ë½ÓзÃÎÊ¿ØÖÆ£©£ºÖ»Äܱ»¸ÃÀà×ÔÉí·ÃÎʺÍÐ޸ġ£ ......