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

JavaÁ½ÖÖÒ쳣ģʽ

JavaÀïÓиöºÜÖØÒªµÄÌØÉ«ÊÇException £¬Ò²¾ÍÊÇ˵ÔÊÐí³ÌÐò²úÉúÀýÍâ×´¿ö¡£¶øÔÚѧJava µÄʱºò£¬ÎÒÃÇÒ²Ö»ÖªµÀException µÄд·¨£¬È´Î´±ØÕæÄÜÁ˽ⲻͬÖÖÀàµÄException µÄÇø±ð¡£
Ê×ÏÈ£¬ÄúÓ¦¸ÃÖªµÀµÄÊÇJava ÌṩÁËÁ½ÖÖException µÄģʽ£¬Ò»ÖÖÊÇÖ´ÐеÄʱºòËù²úÉúµÄException (Runtime Exception)£¬ÁíÍâÒ»ÖÖÔòÊÇÊÜ¿ØÖƵÄException (Checked Exception)¡£
ËùÓеÄChecked Exception ¾ù´Ójava.lang.Exception ¼Ì³Ð¶øÀ´£¬¶øRuntime Exception Ôò¼Ì³Ðjava.lang.RuntimeException »òjava.lang.Error (ʵ¼ÊÉÏjava.lang.RuntimeException µÄÉÏÒ»²ãÒ²ÊÇjava.lang.Exception)¡£
µ±ÎÒÃÇ׫д³ÌÐòµÄʱºò£¬ÎÒÃǺܿÉÄÜ»á¶ÔÑ¡ÔñijÖÖÐÎʽµÄException ¸Ðµ½À§ÈÅ£¬µ½µ×ÎÒÓ¦¸ÃÑ¡ÔñRuntime Exception »¹ÊÇChecked Exception £¿
Æäʵ£¬ÔÚÔË×÷ÉÏ£¬ÎÒÃÇ¿ÉÒÔͨ¹ýClass µÄMethod ÈçºÎ²úÉúij¸öExceptionÒÔ¼°Ä³¸ö³ÌÐòÈçºÎ´¦ÀíÕâ¸ö±»²úÉúÀ´µÄException À´Á˽âËüÃÇÖ®¼äµÄ²îÒì¡£
Ê×ÏÈÎÒÃÇÏȽ¨Á¢Ò»¸öException
public class CException extends Exception
{
public CException() {}
public CException(String message)
{
super(message);
}
}
È»ºóÎÒÃÇ׫дһ¸ö¿ÉÄܲúÉú CException µÄ Class
public class testException
{
public void method1() throws CException
{
throw new CException("Test Exception");
}
public void method2(String msg)
{
if(msg == null)
{
throw new NullPointerException("Message is null");
}
}
public void method3() throws CException
{
method1();
}
// ÒÔÏÂÊ¡ÂÔ
// ...
}
ÔÚÕâÈý¸ömethod ÖУ¬ÎÒÃÇ¿´µ½ÁËmethod1 ºÍmethod2 µÄ³ÌÐòÂëÄÚ¶¼»á²úÉúException£¬µ«method3 µÄ³ÌÐòÂëÖÐ(´óÀ¨ºÅÄÚ)£¬²¢Ã»²úÉúException£¬µ«ÔÚmethod3 µÄ¶¨ÒåÖУ¬°µÊ¾ÁËÕâ¸ömethod ¿ÉÄܲúÉúCException¡£ ºô½Ðmethod1() µÄ³ÌÐò£¬±ØÐ뽫method1() °üº¬ÔÚtry Óëcatch ÖУ¬È磺
public class runtest
{
// ....
public static void main(String argv[])
{
testException te = new testException();
try
{
te.method1();
}
catch(CException ce)
{
// ....
}
}
// ...
}
ËäÈ»°üº¬ÔÚtry Óëcatch ÖУ¬²¢²»±íʾ


Ïà¹ØÎĵµ£º

java³ÌÐòÖе÷ÓÃÉãÏñͷʵÏÖjsp³ÌÐòÉãÏñÍ·Êý¾Ý²É¼¯

½üÆÚµÄÒ»¸öÏîÄ¿ÐèҪʵÏÖÉãÏñͷͼÏñ²É¼¯£¬¾­¹ýһϵÁеÄÕÛÌÚÒÔºó£¬ÖÕÓÚʵÏÖÁËÕâ¸ö¹¦ÄÜ£¬ÏÖÕûÀíһϡ£
±¾Éí¾Íjava¼¼ÊõÀ´Ëµ£¬ÒªÊµÏÖÉãÏñÍ·¶þ´Î¿ª·¢£¬²É¼¯ÉãÏñͷͼƬ£¬ÐèҪʹÓõ½JMF£¬JMFÊʺÏʹÓÃÔÚj2se³ÌÐòµ±ÖУ¬ÎÒÐèÒªÔÚweb³ÌÐòÖе÷ÓÃÉãÏñÍ·£¬ºÜÃ÷ÏÔJMFÊǸ㲻¶¨ÁË£¬Ïë¹ýдһ¸öapplet³ÌÐò£¬Ö»ÊÇÄǶ«Î÷ÒªÇó¿Í»§¶Ë±ØÐëÒªÓÐjre»·¾ ......

JavaÂÛ̳ÊÕ¼¯

×îÇ¿ÁÒÍƼö£­ÎÒµÄjavaÊղؼУ¨ÄÚÓйúÄÚ×îºÃµÄjavaÂÛ̳£©
www.chinajavaworld.com -ÂÛ̳È˺ܶ࣬¸ßÊÖÒ²¶à£¬²»¹ýºÃÏñ¶¼ÔÚDZˮ  
www.cn-java.com -Ò²ºÜ²»´í£¬ÎÄÕºܺ㬵«ÊǾÍÊÇÉÌÒµÐÔŨÁ˵㡣  
www.chinaitlab.com-·Ç³£ÓÐϵͳÐÔ£¬¶øÇÒÍƳöµÄjavaÔ¶³Ì½ÌÓýÊÇÖйú×îÈ«ÃæµÄscjpÔ¶³Ì½ÌÓý¡£ www.huihoo. ......

JAVaÃæÊÔÌâ1

Java»ù´¡·½Ãæ: 
1¡¢×÷ÓÃÓòpublic,private,protected,ÒÔ¼°²»Ð´Ê±µÄÇø±ð
´ð£ºÇø±ðÈçÏ£º
×÷ÓÃÓò           µ±Ç°Àà       Í¬Ò»package  ×ÓËïÀà       ÆäËûpackage
public& ......

ѧjavaµÃÕâÑùѧ£¬Ñ§Ï°¶«Î÷ȷʵҲµÃÕâÑù

Èí¼þ¿ª·¢Ö®Â·ÊdzäÂú¾£¼¬ÓëÌôս֮·,Ò²ÊdzäÂúÏ£Íû֮·¡£JavaѧϰҲÊÇÈç´Ë£¬Ã»Óнݾ¶¿É×ß¡£ÃÎÏëÏñ¡¶ÌìÁú°Ë²¿¡·ÖÐÐéÖñÒ»Ñù±»ÎÞÑÂ×Óõ®õ­¹à¶¥¶øÇáËÉ»ñµÃÒ»¼××Ó¹¦Á¦£¬ÊǺܲ»ÏÖʵµÄ¡£Ã¿ÌìÑöÌì´ó½Ð"ÌìÉñ°¡£¬Çë´Í¸øÎÒÒ»±¾¿û»¨±¦µä°É"£¬Êâ²»Öª¼´Ê¹Äã»ñµÃÁË¿û»¨±¦µä£¬³ýÁËÊÜ×Ô¹¬ÆäÉíÖ®¿àÍ⣬ÄãÒ²²»Ò»¶¨³ÉµÃÁË"¶«·½²»°Ü"£¬µ¹ÊdzÉ"Î÷·½Ê§ ......

Java ÖеÄλÔËËã


ÒÆλÔËËã·û

    °üÀ¨£º
    “>> ÓÒÒÆ”£»“<< ×óÒÆ”£»“>>> ÎÞ·ûºÅÓÒÒÆ”
Àý×Ó£º
-5>>3=-1
1111 1111 1111 1111 1111 1111 1111 1011
1111 1111 1111 1111 1111 1111 1111 1111
Æä½á¹ûÓë Math.floor((double)- ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ