Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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");ÕâÖÖ·½·¨µÄÌصãÊÇÔÚ±à ......

IOÓëÎļþ¶Áд JavaµÄIOÁ÷¼Ü¹¹

¡¾Ò»¡¿»ùÓÚ×Ö½ÚµÄÊäÈëÁ÷
ÖµµÃ×¢ÒâµÄµØ·½ÓУº
¢ÙLevel 2µÄÊäÈëÁ÷£¬´ó¶àÊý¶¼»áÖ¸Ã÷Êý¾ÝÔ´µÄÐÎʽ£ºÀýÈçByteArray£¬File£¬Piped
¢ÚLevel 3µÄÊäÈëÁ÷£¬Ôò²»»á³öÏÖ¾ßÌåµÄÊý¾ÝÔ´Ãû×Ö£¬¶øÊÇÒÔ¹¦ÄÜÈ¡´ú£ºÀýÈçBuffered£¬LineNumber
ËùÒÔ˵Level 3µÄÊäÈëÁ÷ÊǶÔLevel 2ÊäÈëÁ÷µÄ“·â×°ºÍ¹ýÂË”¡£Êµ¼ÊÉÏLevel 2µÄÊäÈëÁ÷£¬¶ ......

JAVAÔËÐл·¾³ÅäÖÃ

Èç¹ûÒªÔËÐÐjava³ÌÐò¾Í±ØÐë°²×°JRE£¨Java Runtime Environment)
Èç¹ûÒª¿ª·¢java³ÌÐò¾Í±ØÐë°²×°JDK£¨Java Develope Kit)
£¬×¢ÒâJDKÖаüÀ¨ÁËJRE¡£
°²×°Íê³Éºó£¬ÐèÒªÐÞ¸Äϵͳ»·¾³±äÁ¿PATH·½·¨£¬²ÅÄÜʹϵͳ֪µÀµ½ÄÄÀïÈ¥ÕÒjavacµÈÏà¹Ø±àÒëÐèÒªµÄÃüÁ·½·¨ÈçÏ£º
1¡¢ÓÒ¼üµ¥»÷ÎҵĵçÄÔ£¬Ñ¡‘ÊôÐÔ’²Ëµ¥£¬ÔÚµ¯³öµÄ¶Ô» ......

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

ËãÊõÒì³£ÀࣺArithmeticExecption
¡¡¡¡¿ÕÖ¸ÕëÒì³£ÀࣺNullPointerException
¡¡¡¡ÀàÐÍÇ¿ÖÆת»»Òì³££ºClassCastException
¡¡¡¡Êý×鸺ϱêÒì³££ºNegativeArrayException
¡¡¡¡Êý×éϱêÔ½½çÒì³££ºArrayIndexOutOfBoundsException
¡¡¡¡Î¥±³°²È«Ô­ÔòÒì³££ºSecturityException
¡¡¡¡ÎļþÒѽáÊøÒì³££ºEOFException
¡¡¡¡ÎļþÎ´Õ ......

AjaxSwing 3.0·¢²¼ ¿É½«Java Swingת»¯ÎªAjax

AjaxSwingÊÇÒ»¸öרΪJava SwingÓ¦Óà ³ÌÐò´òÔìµÄWeb¿ª·¢Æ½Ì¨¡£Ê¹ÓÃAjaxSwing£¬¿ÉÒÔʹΪJava×ÀÃæÓ¦ÓóÌÐòתΪWebÓ¦ÓᣠAjaxSwing¿ÉÒÔ±»¿´×÷ÊÇÒ»¸öJavaµ½HTMLµÄת»»Æ÷£¬Æä³ÌÐò¿ÉÒÔÔÚÔËÐÐʱ´´½¨±»ä¯ÀÀÆ÷½âÎöµÄHTMLºÍ JavaScript¡£ÁíÍ⣬ʹÓÃAjaxSwingÎÞÐè¶Ô³ÌÐòºÍÒµÎñÂß¼­½øÐдó·ùÐÞ¸ÄÐ޸ģ¬ËüÔÊÐí¿ª·¢ÕßʹÓñê×¼Swing×é¼þÀ´Êµ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ