java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.Object

后端 未结 3 1609
我寻月下人不归
我寻月下人不归 2020-12-21 13:07

I\'m running the following query. It displays an error message. How to solve this error?

        ListrouteList=null;
        List compa         


        
3条回答
  •  隐瞒了意图╮
    2020-12-21 13:40

    You can just write:

    vgDetails = new Route();                                 
    vgDetails.setRouteName ((String)companyList.get(i));
    

    companyList is already a list of strings because you select just one column.

    Additionally, as Thilo's answer also suggests, you can cast your result directly to a List instead of using List.

提交回复
热议问题