Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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²úÉú¶ÔÏóµÄ¼¸ÖÖ·½Ê½


Óùؼü×ÖnewÉú³É¶ÔÏó£ºÕâÊÇ×î³£ÓõÄÒ»ÖÖ·½Ê½£¬ÀýÈç new String("hello")ÓÃnewÉú³É¶ÔÏóµÄÌصãÊÇ£¬Õâ¸ö¶ÔÏóµÄÀà±ØÐëÔÚ±àÒëʱ¾ÍÔÚclasspathÖУ¬Èç¹ûûÓÐÌرðµÄÀíÓɺÍÒªÇó£¬ÕâÊÇÎÒÃÇÉú³ÉÒ»¸ö¶ÔÏóµÄµÚһѡÔñ;
Class.forName(String className)¡£ÀýÈçClass c = Class.forName("com.company.jdbc.Driver");ÕâÖÖ·½·¨µÄÌصãÊÇÔÚ±à ......

java doc µÄ°ü×¢ÊÍ

ÏàÐÅ´ó¼Ò¶¼ÓÃjavadocµÄÃüÁîÉú³É¹ýapi help °É£¿µ«ÊÇ°ü×¢ÊÍÔõôÀ´µÄÄØ£¿½ñÌìѧϰԴ´úÂëµÄʱºò·¢ÏÖÁËÕâ¸ö°ü×¢Ê͵ÄÀ´Ô´¡£
±ÈÈ磺org.apache.james.utilÕâ¸öµÄ°ü×¢ÊÍ¡£ÔÚÕâ¸ö°üϱßÓÐÒ»¸öpackage.htmlµÄÎļþ¡£
<body>
<p>A variety of utility classes used inside James.</p>
</body>

ÕâÑùÔÙÓ ......

һЩ³£¼ûJavaÒì³£¹éÀà(Ò»)

UnsupportedClassVersionError
¡¡¡¡²»Ö§³ÖµÄÀà°æ±¾´íÎó¡£µ±JavaÐéÄâ»úÊÔͼ´Ó¶Áȡij¸öÀàÎļþ£¬µ«ÊÇ·¢ÏÖ¸ÃÎļþµÄÖ÷¡¢´Î°æ±¾ºÅ²»±»µ±Ç°JavaÐéÄâ»úÖ§³ÖµÄʱºò£¬Å׳ö¸Ã´íÎó¡£
¡¡¡¡java.lang.VerifyError
¡¡¡¡ÑéÖ¤´íÎó¡£µ±ÑéÖ¤Æ÷¼ì²âµ½Ä³¸öÀàÎļþÖдæÔÚÄÚ²¿²»¼æÈÝ»òÕß°²È«ÎÊÌâʱÅ׳ö¸Ã´íÎó¡£
¡¡¡¡java.lang.VirtualMachineErr ......

һЩ³£¼ûJavaÒì³£¹éÀà(¶þ)

ËãÊõÒì³£ÀࣺArithmeticExecption
¡¡¡¡¿ÕÖ¸ÕëÒì³£ÀࣺNullPointerException
¡¡¡¡ÀàÐÍÇ¿ÖÆת»»Òì³££ºClassCastException
¡¡¡¡Êý×鸺ϱêÒì³££ºNegativeArrayException
¡¡¡¡Êý×éϱêÔ½½çÒì³££ºArrayIndexOutOfBoundsException
¡¡¡¡Î¥±³°²È«Ô­ÔòÒì³££ºSecturityException
¡¡¡¡ÎļþÒѽáÊøÒì³££ºEOFException
¡¡¡¡ÎļþÎ´Õ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ