public class CatchsDemo {
public static void main(String args[]){
String x = "";
String y = "";
int i = 0;
int j = 0;
try{
x = args[0];
y = args[1];
i = Integer.parseInt(x);
j = Integer.parseInt(y);
}catch(IndexOutOfBoundsException e){
System.out.println("沒有輸入命令列引數");
System.exit(0);
}catch(NumberFormatException e){
System.out.println("輸入資料格式不正確");
return;
}
finally{
System.out.println("輸入的第一個資料為:" + x + " 輸入的第二個資料為:" + y);
int sun = 0; int mun = 0;
sun = i / j;
mun = i % j;
System.out.println("兩個數的商為:" + sun + " 兩個數的餘數為:" + mun);
System.out.println("here is the end of the program");
public class CatchsDemo {
public static void main(String args[]){
String x = "";
String y = "";
int i = 0;
int j = 0;
try{
x = args[0];
y = args[1];
i = Integer.parseInt(x);
j = Integer.parseInt(y);
}catch(IndexOutOfBoundsException e){
System.out.println("沒有輸入命令列引數");
System.exit(0);
}catch(NumberFormatException e){
System.out.println("輸入資料格式不正確");
return;
}
finally{
System.out.println("輸入的第一個資料為:" + x + " 輸入的第二個資料為:" + y);
int sun = 0; int mun = 0;
sun = i / j;
mun = i % j;
System.out.println("兩個數的商為:" + sun + " 兩個數的餘數為:" + mun);
}
System.out.println("here is the end of the program");
}
}