JAVA int 強制型別轉換錯誤提示(Cannot cast from Object to int)

dj0379發表於2015-10-15
2013-06-19 16:20:20
在將ANDROID原始碼匯入eclipse時,出錯提示如下:
    public void addActiveCid(int cid) {
        if (cidActiveList == null) {
            cidActiveList = new ArrayList();
        }
        for (int i=0;i
            if(cid == cidActiveList.get(i)) {                 // 行 657
                return;
            }
        }
        cidActiveList.add(cid);
        Log.d(LOG_TAG, "[" + phone.getPhoneId() + "]addActiveCid("+cid+") cidActive("+cidActive+") List("+cidActiveList+")");
    }
    public void removeActiveCid(int cid) {
        if (cidActiveList != null) {
            for (int i=0;i
                if(cid == cidActiveList.get(i)) {          // 行667.
                    cidActiveList.remove(i);
                }
            }
        }

Incompatible operand types int and Object    DataConnectionTracker.java   /check/frameworks/base/telephony/java/com/android/internal/telephony    line 657    Java Problem

Incompatible operand types int and Object    DataConnectionTracker.java   /check/frameworks/base/telephony/java/com/android/internal/telephony    line 667    Java Problem

將 if(cid == cidActiveList.get(i))加入強制轉換int後,即

           if(cid == (int)cidActiveList.get(i))
又出現如下錯誤提示:
Cannot cast from Object to int    DataConnectionTracker.java   /check/frameworks/base/telephony/java/com/android/internal/telephony    line 657 

相關文章