Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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±Ê¼Ç

ÅäÖÃjava»·¾³±äÁ¿£º     JAVA_HOME£ºÅäÖÃJDKµÄĿ¼     CLASSPATH£ºÖ¸¶¨µ½ÄÄÀïÈ¥ÕÒÔËÐÐʱÐèÒªÓõ½µÄÀà´úÂ루×Ö½ÚÂ룩     PATH£ºÖ¸¶¨¿ÉÖ´ÐгÌÐòµÄλÖà     LINUXϵͳ£¨ÔÚ" .bash_profile "ÏµĻ·¾³±äÁ¿ÉèÖã©        ......

javaÀûÓÃsmslib·¢ËͶÌÐÅ

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µÄ½øÒ»²½·â×°,¿ÉÒÔÖ±½Ó·¢ ......

´Ó×·MM̸JavaµÄ23ÖÖÉè¼ÆÄ£Ê½

¡¡1¡¢FACTORY—×·MMÉÙ²»ÁËÇë³Ô·¹ÁË£¬Âóµ±À͵靈áºÍ¿ÏµÂ»ùµÄ¼¦³á¶¼ÊÇMM°®³ÔµÄ¶«Î÷£¬ËäÈ»¿ÚζÓÐËù²»Í¬£¬µ«²»¹ÜÄã´øMMÈ¥Âóµ±ÀÍ»ò¿ÏµÂ»ù£¬Ö»¹ÜÏò·þÎñԱ˵“À´Ëĸö¼¦³á”¾ÍÐÐÁË¡£Âóµ±ÀͺͿϵ»ù¾ÍÊÇÉú²ú¼¦³áµÄFactory
¡¡¡¡¹¤³§Ä£Ê½£º¿Í»§ÀàºÍ¹¤³§Àà·Ö¿ª¡£Ïû·ÑÕßÈκÎʱºòÐèҪijÖÖ²úÆ·£¬Ö»ÐèÏò¹¤³§ÇëÇó¼´¿É¡£Ïû· ......

javaÖÐThreadÏß³ÌÖÐµÄ start£¨£©ºÍrun£¨£©·½·¨µÄÇø±ð


Á½ÖÖ½¨Á¢Ï̶߳ÔÏóµÄ·½·¨£º
    Extends Thread
    implement Runnable
   ÕâÁ½ÖÖ·½·¨¶¼¿ÉÒÔ´´½¨Ò»¸öÏ̶߳ÔÏó£¬
public class TestThread {
    public static void main(String arg[]){
        newThread thread = new ne ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ