sex==0?0:1; 出錯

cannot convert from int to boolean

    //根據身份證號碼判斷性別(18位身份證)
    private int discernSexByIdCode(String str){
        int sex = 0;
        if (str.length()==18) {
             int n = str.charAt(17);
                sex = n%2;
                if (sex==0) {
                    sex=1;
                } else {
                    sex=2;
                }
        }
        return sex;
    }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章