返回列表 發帖

1217 try catch

本帖最後由 b790113g 於 2011-12-17 10:19 編輯 3 X9 z5 ?! M+ D+ m
9 P6 s" h3 e9 L- M% M
同上題8 R) X5 s$ R( k

1 Z. M+ Y, j; m3 v$ R& u! U7 G! @輸入兩個參數做數值運算
+ S0 c8 U, g  }4 u% V% v, _3 T, T
- ^6 h. Q# ^8 V4 i, L7 g若參數不足提示使用者
  1. public class d1217{

  2.     public static void main(String[] arg){
  3.         
  4.                 //if(arg.length<2) return ;
  5.      
  6.                 try{
  7.                         System.out.println(arg[0]+arg[1]);
  8.                 }catch(Exception e){
  9.                         System.out.println("參數不足"+e.toString());
  10.                 }
  11.         
  12.                
  13.     }

  14. }
複製代碼

  1. public class d1217{
  2.     public static void main(String[] arg){
  3.             //if(arg.length<2)return ;
  4.                 try{
  5.                     System.out.println(arg[0]+arg[1]);
  6.                 }catch(Excrption e){
  7.                 System.out.println("參數不足"+e.toString());
  8.         }
  9. }
複製代碼
★ 嘉凱~~☆

TOP

public class d1217{
; z' _5 K  n) z5 X- c1 E. s* B) n+ o1 D; }6 K* P& @
    public static void main(String[] arg){
- \# y/ A# t- o2 E7 A
0 U1 u; |4 G# d1 z& H" ?            //if(arg.length<2)return ;, K- s. V3 t  {  c/ y
# ^5 e1 O. K3 D: L( S9 f8 S& ]
                try{
9 f( Y6 R, G6 B0 z( P# {- I  G; R! o6 B6 Z# D/ a0 o2 }* K7 u
                    System.out.println(arg[0]+arg[1]);8 |0 _1 \9 l$ N, ~
' E- m/ t5 p0 L# H1 E8 R* s  O& A
                }catch(Excrption e){
7 X* k" E) I( U: D0 @& e% W& |; V
- i' M9 ~# d3 d) M' Y                System.out.println("參數不足)"+e.toString());: c  j6 [3 @1 m; m, }+ ^

, \* n- s' D& o- T9 |; D        }! T1 d- F! I: F7 ]3 ^! u

6 c; H9 D' c* \0 s) A, V: _}
人平

TOP

public class d1217{1 I: j( b: T3 \0 T. t# @5 n
. h, U0 [$ I  S% g/ M" u' u( [
    public static void main(String[] arg){0 ?+ R- i5 }. \& G; \* g

0 A* X. Y5 I- q3 a# X            //if(arg.length<2)return ;' a+ D& N4 t5 n: d5 s( S& l2 @
/ @% I1 U( ~, e) c5 N) u, H3 S# g
                try{
, \0 E% X: k" ~- {& D, Y/ D2 ~+ a# B
                    System.out.println(arg[0]+arg[1]);& w0 b5 e9 ~# x" ?* H& k
( W3 t) U) z1 j0 t' H
                }catch(Excrption e){& h7 I2 f3 D: R1 D

4 P0 A* k5 N1 V% ~8 k                System.out.println("參數不足"+e.toString());
7 l# C; R& ~" S! m7 r+ A
2 U/ C3 @5 A+ k* I        }
4 D8 b- a3 e3 z7 x) D
& V, L5 W) }- a6 T+ n}
人平

TOP

  1. public class a1224
  2. {
  3.     public static void main(String[]arg)
  4.         {
  5.                 try
  6.                 {
  7.                 System.out.println(Integer.parseInt(arg[0])+Integer.parseInt(arg[1]));
  8.                 }
  9.             cath(Exception e)
  10.                 {
  11.                 System.out.println("參數不足");
  12.                 }
  13.     }




  14. }
複製代碼
水桶小鄭,鯰魚

TOP

  1. public class j3{
  2.         public static void main(String[] arg){
  3.                 try{
  4.                 System.out.println(Integer.parseInt(arg[0])+Integer.parseInt(arg[1]));
  5.         }catch(Exception e){
  6.          System.out.println("參數不足");
  7.         }
  8.         }
  9. }
複製代碼
陳彥綸

TOP

返回列表