返回列表 發帖
package site.istak.org.tw;

public class Main {
        public static void main(String args[]){
                String num1 = "100";
                String num2 = "a";
        int total=0;
       try{
            total=Integer.parseInt(num1)+Integer.parseInt(num2);
                System.out.println(total);
                }
                catch(Exception ex){
                        num2="10";
                        total=Integer.parseInt(num1)+Integer.parseInt(num2);
                        System.out.println(total);
                        }
                finally{
                        total+=100;
                    System.out.println(total);
                }
        }
}

TOP

package site.istak.org.tw;

public class Main {
        public static void main(String args[]){
                String num1 = "100";
                String num2 = "a";
        int total=0;
       try{
            total=Integer.parseInt(num1)+Integer.parseInt(num2);
                System.out.println(total);
                }
                catch(Exception ex){
                        num2="0";
                        total=Integer.parseInt(num1)+Integer.parseInt(num2);
                        System.out.println(total);
                        }
                finally{
                        total+=100;
                    System.out.println(Math.pow(total, 2));
                }
        }
}

TOP

返回列表