How to Convert List to List<Object>

前端 未结 7 1387
忘了有多久
忘了有多久 2020-11-30 03:47

I want to convert List to List.

One of the existing methods is returning List and I

7条回答
  •  爱一瞬间的悲伤
    2020-11-30 04:17

    Any java collection is just a collection of objects be it string or other. The type argument is just sugar. Depending on situation, such as dealing with very large lists, you may just want to convert it - obviously risking mixing two different types of objects in the same list.

    List objectList = (List)stringList;
    
    
    

    And put a @SuppressWarning to get rid of nasties...

    提交回复
    热议问题