ã¯ããã«
é çªãåå¾ãã¾ãããä»å㯠Java ã®ç¹å¾´ã®ã²ã¨ã¤ã§ããä¾å¤æ©æ§ã«ã¤ãã¦ã§ãã
ä»åã®ç¯å²
223 ãã¼ã¸ ã 250 ãã¼ã¸
ååã¯ãã¡ã
Java ã®ä¾å¤
- throw å¯è½ãªãªãã¸ã§ã¯ã
- Throwable ã¤ã³ã¿ãã§ã¼ã¹ãå®è£ ãããã®
- Exception ãç¶æ¿ããªã Throwable ã¯åºæ¬çã«ä½¿ããªã
- ãã§ãã¯ä¾å¤
- ã¡ã½ããã®å®è£ è ããå¼ã³åºãå ãå復å¯è½ãã ã¨èãã¦ããä¾å¤
- ã¡ããã¨ããªããä¾å¤ã ã£ãã®ããçç±ãæä¾ãããã¹ã
- å¼ã³åºãå 㯠try catch ã§å²ãã throws 宣è¨ãæ¸ãå¿ è¦ããã
- Exception ãç¶æ¿ãã¦ã㦠RuntimeException ãç¶æ¿ãã¦ããªãã¯ã©ã¹
- å®è¡æä¾å¤
- äºåæ¡ä»¶éåï¼ä»æ§ã§æ確ã«å®ç¾©ãããæ¡ä»¶ãæããªãç¶æ ã§ã¡ã½ãããå¼ã³åºããããã¨ï¼ãéç¥ããæ段ã¨ãã¦ä½¿ããã
- å®è¡æã«ãããçºçããå ´åã¯ãã¡ã½ããã®å¼ã³åºãå ãã³ã¼ããç´ãã¹ã
- å¼ã³åºãå ã try catch ã throws ãæ¸ãå¿ è¦ããªã
- RutimeException ãç¶æ¿ããã¯ã©ã¹
- ã¨ã©ã¼
- JVM ã使ã
ã¡ãã£ã¨ã¤ã¡ã¼ã¸ã沸ããããããã«å°è©ã§è¨ãæãã¦ã¿ã
ãã§ãã¯ä¾å¤
ç·åã好ãã§ãï¼ä»ãåã£ã¦ãã ããï¼ãï¼ã¡ã½ããã®å®è¡ï¼
女åãå¥ã«å¥½ããªç·ã®åããããã§ãï¼ãï¼å復å¯è½ä¾å¤ãçç±ä»ãï¼
ç·åãããããåéã«ãªã£ã¦ï¼ç¸è«ã¨ãã®ããï¼ãï¼å復ï¼
å®è¡æä¾å¤
ç·åã好ãã§ãï¼ä»ãåã£ã¦ãã ããï¼ãï¼ã¡ã½ããã®å®è¡ï¼
女åãããããªã誰ã§ããï¼ï¼ãï¼äºåæ¡ä»¶éåï¼
â
ä¿®æ£
â
ç·åãã¯ããã¾ãã¦ã以åæåç¥ã§ãã§ã³ãããã売ã£ã¦ã¾ããããã
女åãã¯ãã
ç·åãããåãã®ã¨ã客ã¨ãã¦è¡ã£ãã®è¦ãã¦ã¾ãï¼ã
女åããã¼ï¼ãã®ã¨ãã®ï¼ãï¼äºåæ¡ä»¶ï¼
æã¯æµãã¦â¦
ç·åã好ãã§ãï¼ä»ãåã£ã¦ãã ããï¼ãï¼ã¡ã½ããã®å®è¡ï¼
女åããã¡ãããï¼ãï¼æåï¼
ã¨ã©ã¼
ç·åã好ãã§ãï¼ä»ãåã£ã¦ãã ããï¼ãï¼ã¡ã½ããã®å®è¡ï¼
女åãâ¦ã
女åãâ¦ã
女å(ç¥)ãç§ã ãï¼ã¨ã©ã¼ï¼
ç·å(ç¥)ããåã ã£ãã®ãã
女å(ç¥)ãæãæã¦ä½ãããç¥ã
ã®ã
ç·å(ç¥)ãéã³ã
-- ããã°ã©ã çµäº --
ãã§ãã¯ä¾å¤ã¯è² è·ãé«ã
try catch ã¯ä½¿ãå´ã®ã³ã¼ããé常ã«ç ©éã«ãªã
ãã§ãã¯ä¾å¤ãçã¿ã ãç ©éããæ£å½ããèãã
ãã§ãã¯ä¾å¤ã¯ä½¿ãå´ã®ã³ã¼ããç ©éã«ãããã©ã以ä¸ã®äºã¤ã®æ¡ä»¶ãæç«ããå ´åããã®ç ©éãã¯æ£å½åãããã
- ãã®ä¾å¤ãçºçããäºåæ¡ä»¶ãå®ç¾©ã§ããªã
- å¼ã³åºãå ãã catch ããã¨ãã«æç¨ãªå¦çãæ¸ããï¼ä¾å¤ãããªãããã®æ å ±ãæã£ã¦ããï¼
ãã®äºã¤ã®æ¡ä»¶ãæºãããªãå ´åã¯ãå®è¡æä¾å¤ã«ããã¹ã
ãã¨ãã°ãå¼ã³åºãå
ã e.printStackTrace() ããããããããã¨ããªããã ã£ãããå®è¡æä¾å¤ã«ãã¦ãã¾ããã
æ¨æºä¾å¤ã使ãã
- IllegalArgumentException
- IllegalStateException
- NullPointerException
- IndexOutOfBoundsException
- ConcurrentModificationException
- UnsupportedOperationExcption
ãªã©ãæ¨æºä¾å¤ã§ç¨æããã¦ãããã®ã¯ç©æ¥µçã«ä½¿ããï¼
æ½è±¡æ¦å¿µã«çããä¾å¤ãæãã
é©åã«ä¾å¤ç¿»è¨³ãããã
ãã¨ãã°ã findUser ã¨ãã£ã¦ããã¡ã½ãããã SQLException ãæãããã¡ãã ãã§ã UserNotFoundException ã¨ãã«ããã»ããããã
ãã ããä½ã§ãä¾å¤ç¿»è¨³ããã°ãããã¯ãã¡ãå¯è½ãªãããã®ã¡ã½ããå
ã§ä¾å¤ãçºçããªããã¨ãä¿è¨¼ãããã
ä¾å¤ãææ¸åããã
- ãã§ãã¯ä¾å¤ã¯ @throws ã«æ¸ã
- å®è¡æä¾å¤ã¯ javadoc ã® @throws ã«ã¯æ¸ããã©ã¡ã½ããã® throws ã«ã¯æ¸ããªã
ä¾å¤ã®ã¡ãã»ã¼ã¸ã«è©³ç´°ãªæ å ±ãå«ãã
ä¾å¤ã®æåå表ç¾ã¯ããã®ä¾å¤ã®åå ã¨ãªã£ãå
¨ã¦ã®æ
å ±ãå«ãã§ããã¹ãã
以ä¸ã®ãããªã¤ãã£ãªã ã§æ¸ãã¨ããã
// ã³ã³ã¹ãã©ã¯ã¿ã§å¿ è¦ãªæ å ±ããã¹ã¦åãåã public FooException(int foo, String bar, long baz) { // 詳細ã¡ãã»ã¼ã¸ãä½ã super("foo: " + foo + ", bar: " + bar + ", baz: " + baz); // ãã£ã¼ã«ãã«è¨é²ãã this.foo = foo; this.bar = bar; this.baz = baz; }
ã¨ã©ã¼ã¢ãããã¯æ§
ãããéè¦ã
ã¨ã©ã¼ãä¾å¤ãçºçããå ´åã¯ããªãã¸ã§ã¯ãã®ç¶æ
ãã¡ã½ããå¼ã³åºãåã®ç¶æ
ã«æ»ãã¦ãããã
ãã㯠JavaScript ããã£ã¦ã¦ãããæããã¨
ãã¨ãã°è¤é㪠DOM ãæ§ç¯ãããããªã¡ã½ããã§ã¨ã©ã¼ãçºçããå ´åã« DOM ã«ã´ãããã£ã±ããã£ã¤ããç¶æ ã«ãªã£ã¦ãã¾ããã¨ãå¤ã
ã¨ã©ã¼çºçæã«å é¨ã§ä¸å catch ãã¦ç¶ºéºã«ãããªã©ã¨ã©ã¼ã¢ãããã¯ã«ãã¦ãããã¨ãéè¦ã
ä¾å¤ãç¡è¦ããªã
ãã§ãã¯ä¾å¤ã¯ãæ¡ãã¤ã¶ããªãã
ä¾å¤ãç¡è¦ãã¦ãããå ´åã¯ããã®çç±ã catch ãããã¯ã«è¨è¿°ããã
äºåæ¡ä»¶ãªã©ã§ãä¾å¤ãçºçããªããã¨ã確å®ãªã AssertionError ãæãããªã©ããã
ä¾å¤ä»¥å¤ã®ãã¨
ä¾å¤ä»¥å¤ã®é ç®ã«æ¸ãã¦ãã£ããã¨
ãªãã¬ã¯ã·ã§ã³
- ã³ã³ãã¤ã«æã®æ¤æ»ããªã
- ããã¡ãªãã¦ãåé·
- ããã©ã¼ãã³ã¹ãæªã
ããã¾ãã¡ãªãããªãã
ãã¬ã¼ã ã¯ã¼ã¯ã¨ãä½ãã¨ãã«ã¯ä½¿ããããã¼
ãã¤ãã£ãã¡ã½ãã
JNI 㧠C/C++ ã§æ¸ãããã¡ã½ãããå¼ã¹ãã
çµæ§ãããã©ãããã
é度ã®ããã«ããã®ã¯ããªã¹ã¹ã¡ããªãã
æè¿ã® Java ã¯éãããã
注æãã¦æé©åãã
ã¾ãã¯ãæé©åãªããããª
æé©åããåã«ãããã¡ã¤ãªã³ã°ãªã©ãã¡ããã¨ãããã
å½åè¦ç´
空æ°ãèªãã§ãååä»ããã¾ãããã
ã¾ã¨ã
ããï¼ Java ã®ãã§ãã¯ä¾å¤ã¡ããã£ããã©ãããï¼