[問題]簡單assert程式,執行結果卻不如預期
我的程式命名為AssertReplaceIf.java
-------------------------------------------------------------
//"assert" replace "if" 設中斷點, 寫完程式後不需刪除assert
import java.util.*;
public class AssertReplaceIf{
public static void main(String[] args){
Scanner sKBinput=new Scanner(System.in);
int ivalue=sKBinput.nextInt();
int ia=ivalue/100;
assert ia!=0;//true則繼續執行,false則中斷程式
int ib = 123/ia;
System.out.println(ib);
}//end main
}//end calss AssertReplaceIf
-------------------------------------------------------------
此程式用javac AssertReplaceIf.java編譯
用java -ea AssertReplaceIf執行
可是當我輸入數字0與數字3時,程式都會中斷
我不知道哪裡出錯了
哪位高人可以指點一下
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.68.161.27
→
08/11 11:05, , 1F
08/11 11:05, 1F
→
08/11 11:11, , 2F
08/11 11:11, 2F
推
08/11 11:55, , 3F
08/11 11:55, 3F