¼Ò½ºÄÚµå¶óÀ̺귯¸®  ¿¹¿Ü󸮠 throws ±¸¹®  

throws ±¸¹®

PassException.java

import java.net.*; 
public class 
PassException { 
    
public URL makeURL(String urlstr) throws 
MalformedURLException{ 
        
return new 
URL(urlstr); 
    } 
    
public static void 
main(String args[]) { 
        PassException p = 
new 
PassException(); 
        
try
{          
                URL url = p.makeURL(
"http://www.yahoo.co.kr"
); 
                
//Á¤È®ÇÑ URLÀ» ÀÔ·ÂÇÏÁö ¾Ê¾Æ?shy; ¿¡·¯¹ß»ý 
                
System.out.println(url); 
        } 
catch
(MalformedURLException e) { 
                System.out.println(
"--MalformedURLException ¹ß»ý±¸¹®--"
); 
                System.out.println(
"Á¤º¸:e.getMessage(): " 
+ e.getMessage()); 
                System.out.println(
"Á¤º¸:e.toString(): " 
+ e.toString()); 
                System.out.print(
"Á¤º¸:e.printStackTrace():"
);e.printStackTrace(); 
                
return

        } 
finally

            System.out.println(
"finally: °á±¹À̸®·Î ¿À´Â±º¿ä"
); 
        } 
    } 
}

C:\examples\7. Exception>javac PassException.java
C:\examples\7. Exception>java PassException
http://www.yahoo.co.kr
finally: °á±¹À̸®·Î ¿À´Â±º¿ä

throwsŰ¿öµå´Â ¿¡·¯À̺¥Æ®¸¦ ¸Þ¼­µå³»ºÎ¿¡¼­ ó¸®ÇÏÁö ¾Ê°í, ¸Þ¼­µå¸¦ »ç¿ëÇÒ¶§ ¿¡·¯Ã³¸®¸¦ Çϵµ·Ï ¿¡·¯Ã³¸®¸¦ ¹Ì·ç´Â ¶§ ¾²´Â Ű¿öµåÀÔ´Ï´Ù. ¾ÕÀÇ throw Ű¿öµå¿Í È¥µ·ÇÏÁö ¸» °Í!!!



jabookÀúÀÚ¸íÇÔ
Á¦¸ñ:°´Ã¼°³³ä¼Ò½ºÄÚµå
ÀúÀÚ:ÃÖ¿µ°ü