JAVAÒì³£×Ü½á ¼Ì³Ð
ÒÔÏÂÊǶÔJAVAÒì³£µÄ¼Ì³Ð»úÖÆµÄһЩ×ܽᡣ
1. RuntimeExceptionÓëException, Error²»Í¬µã£º µ±·½·¨ÌåÖÐÅ׳ö·ÇRuntimeException£¨¼°Æä×ÓÀࣩʱ£¬·½·¨Ãû±ØÐëÉùÃ÷Å׳öµÄÒì³££»µ«Êǵ±·½·¨ÌåÖÐÅ׳öRuntimeException£¨°üÀ¨RuntimeException×ÓÀࣩʱ£¬·½·¨Ãû²»±ØÉùÃ÷¸Ã¿ÉÄܱ»Å׳öµÄÒì³££¬¼´Ê¹ÉùÃ÷ÁË£¬JAVA³ÌÐòÔÚij¸öµ÷Óõĵط½£¬Ò²²»ÐèÒªtry-catch´Ó¾äÀ´´¦ÀíÒì³£¡£
class TestA{
//compiles fine.we don't need to claim the RuntimeException to be thrown here
void method(){
throw new RuntimeException();
}
}
class TestB{
void method() throws RuntimeException{
throw new RuntimeException();
}
void invokeMethod(){
//compiles fine. we don't need the try-catch clause here
method();
}
}
class TestC{
//compiles error.we need to claim the Exception to be thrown on the method name
void method(){
throw new Exception();
}
}
class TestD{
//compiles fine.
void method() throws Exception{
throw new Exception();
}
}
ÒÔÏÂËùÓеÄÏà¹ØÒì³£µÄÌØÐÔ¶¼²»°üÀ¨RuntimeException¼°Æä×ÓÀà¡£
2. ¼ÙÈçÒ»¸ö·½·¨ÔÚ¸¸ÀàÖÐûÓÐÉùÃ÷Å׳öÒì³££¬ÄÇô£¬×ÓÀา¸Ç¸Ã·½·¨µÄʱºò£¬²»ÄÜÉùÃ÷Òì³£¡£
class TestA{
void method(){}
}
class TestB extends TestA{
//complies error if the method overrided pertaining to the base class doesn't declare throwing exceptions
void method() throws Exception{
throw new Exception();
}
}
3. ¼ÙÈçÒ»¸ö·½·¨ÔÚ¸¸ÀàÖÐÉùÃ÷ÁËÅ׳öÒì³££¬×ÓÀา¸Ç¸Ã·½·¨µÄʱºò£¬ÒªÃ´²»ÉùÃ÷Å׳öÒì³££¬ÒªÃ´ÉùÃ÷±»Å׳öµÄÒì³£¼Ì³Ð×ÔËüËù¸²¸ÇµÄ¸¸ÀàÖеķ½·¨Å׳öµÄÒì³£¡£
class TestA{
void method() throws RuntimeException{}
}
class TestB extends TestA{
//compiles fine if current method does not throw any exceptions
void method(){}
}
class TestC extends TestA{
//compiles fine because NullPointerException is inherited from RuntimeException which is thrown by the overrided method of the base class
void method() throws NullPointerException{}
}
class TestD extends TestA{
//compiles error because Exception thrown by current method is not inherited from RuntimeException which is thr
Ïà¹ØÎĵµ£º
ÅäÖÃjava»·¾³±äÁ¿£º JAVA_HOME£ºÅäÖÃJDKµÄĿ¼ CLASSPATH£ºÖ¸¶¨µ½ÄÄÀïÈ¥ÕÒÔËÐÐʱÐèÒªÓõ½µÄÀà´úÂ루×Ö½ÚÂ룩 PATH£ºÖ¸¶¨¿ÉÖ´ÐгÌÐòµÄλÖà LINUXϵͳ£¨ÔÚ" .bash_profile "ÏµĻ·¾³±äÁ¿ÉèÖã© ......
javaÀûÓÃsmslib·¢ËͶÌÐÅ.
×Ô¼ºÐ´Ò»¸öС³ÌÐò,ÎÒÔÚjava1.6.0_10;smslib-v3.4.5ÏÂÔËÐгɹ¦. ¿ÉÒÔÎÒµÄ×ÊÔ´ÀïÃæÏÂÔØ.
http://hi.csdn.net/link.php?url=http://yangzl0123.download.csdn.net
,Ö÷ÒªÊÇÒÔϼ¸¸öÀà.
Level_Final_Serial.java:´®¿Úµ×²ã²Ù×÷
Serial_For_Smslib.java:¶ÔLevel_Final_SerialµÄ½øÒ»²½·â×°,¿ÉÒÔÖ±½Ó·¢ ......
¡¡1¡¢FACTORY—×·MMÉÙ²»ÁËÇë³Ô·¹ÁË£¬Âóµ±À͵靈áºÍ¿ÏµÂ»ùµÄ¼¦³á¶¼ÊÇMM°®³ÔµÄ¶«Î÷£¬ËäÈ»¿ÚζÓÐËù²»Í¬£¬µ«²»¹ÜÄã´øMMÈ¥Âóµ±ÀÍ»ò¿ÏµÂ»ù£¬Ö»¹ÜÏò·þÎñԱ˵“À´Ëĸö¼¦³á”¾ÍÐÐÁË¡£Âóµ±ÀͺͿϵ»ù¾ÍÊÇÉú²ú¼¦³áµÄFactory
¡¡¡¡¹¤³§Ä£Ê½£º¿Í»§ÀàºÍ¹¤³§Àà·Ö¿ª¡£Ïû·ÑÕßÈκÎʱºòÐèҪijÖÖ²úÆ·£¬Ö»ÐèÏò¹¤³§ÇëÇó¼´¿É¡£Ïû· ......
¡¾Ò»¡¿»ùÓÚ×Ö½ÚµÄÊäÈëÁ÷
ÖµµÃ×¢ÒâµÄµØ·½ÓУº
¢ÙLevel 2µÄÊäÈëÁ÷£¬´ó¶àÊý¶¼»áÖ¸Ã÷Êý¾ÝÔ´µÄÐÎʽ£ºÀýÈçByteArray£¬File£¬Piped
¢ÚLevel 3µÄÊäÈëÁ÷£¬Ôò²»»á³öÏÖ¾ßÌåµÄÊý¾ÝÔ´Ãû×Ö£¬¶øÊÇÒÔ¹¦ÄÜÈ¡´ú£ºÀýÈçBuffered£¬LineNumber
ËùÒÔ˵Level 3µÄÊäÈëÁ÷ÊǶÔLevel 2ÊäÈëÁ÷µÄ“·â×°ºÍ¹ýÂË”¡£Êµ¼ÊÉÏLevel 2µÄÊäÈëÁ÷£¬¶ ......
UnsupportedClassVersionError
¡¡¡¡²»Ö§³ÖµÄÀà°æ±¾´íÎó¡£µ±JavaÐéÄâ»úÊÔͼ´Ó¶Áȡij¸öÀàÎļþ£¬µ«ÊÇ·¢ÏÖ¸ÃÎļþµÄÖ÷¡¢´Î°æ±¾ºÅ²»±»µ±Ç°JavaÐéÄâ»úÖ§³ÖµÄʱºò£¬Å׳ö¸Ã´íÎó¡£
¡¡¡¡java.lang.VerifyError
¡¡¡¡ÑéÖ¤´íÎó¡£µ±ÑéÖ¤Æ÷¼ì²âµ½Ä³¸öÀàÎļþÖдæÔÚÄÚ²¿²»¼æÈÝ»òÕß°²È«ÎÊÌâʱÅ׳ö¸Ã´íÎó¡£
¡¡¡¡java.lang.VirtualMachineErr ......