list參數傳入不改變-06-14

private long getlistByType(JSONObject jsonObject, String type, List<JSONObject> list) {
        long count = -1;

        //欠租
        if ("arrear".equals(type)) {
            list = rentorderDao.listRiskOrderCar(jsonObject);
            count = rentorderDao.listCountRiskOrderCar(jsonObject);
        }


        //保險到期
        else if ("insurance".equals(type)) {
            list = customerCarDao.listInsuranceRisk(jsonObject);
            count = customerCarDao.listCountInsuranceRisk(jsonObject);
        }

        //年檢到期
        else if ("yearlyReview".equals(type)) {
            list = customerCarDao.listYearlyReviewRiskList(jsonObject);
            count = customerCarDao.listCountYearlyReviewRiskList(jsonObject);
        }

        //違章
        else if ("peccancy".equals(type)) {
            list = customerCarDao.listPeccancyRiskList(jsonObject);
            count = customerCarDao.listCouuntPeccancyRiskList(jsonObject);
        }

        //超速
        else if ("speeding".equals(type)) {
            list = gpsAlertDao.speedingList(jsonObject);
            count = gpsAlertDao.speedingCount(jsonObject);
        }

        //設備離線
        else if ("offline".equals(type)) {
            list = gpsAlertDao.offlineList(jsonObject);
            count = gpsAlertDao.offlineCount(jsonObject);
        }

        return count;
    }

調用該方法的list還是爲沒有值

因爲是引用數據類型,是一個list的引用 ,調用dao的方法之後重新指向一個新的值,所以原來的那個值從來沒有改變。


所以要怎麼要將這個方法抽象出來呢

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