1. 程式人生 > >報錯:Cannot instantiate the type Map(String ,Object)

報錯:Cannot instantiate the type Map(String ,Object)

錯誤資訊

Cannot instantiate the type Map<String,Object>

無法例項化Map

錯誤程式碼

       //航節資訊驗證
        Map<String,Object>  fisrstMapSection = new Map<String, Object>();

錯誤原因

這裡是對基礎知識不好導致,map是一個抽象的介面,不能直接例項化,可以使用它的具體的實現類

        Map<String,Object>  fisrstMapSection = new HashMap<String, Object>();