How to Get class of Elements that List Contains?

前端 未结 4 405
醉梦人生
醉梦人生 2021-01-18 01:47

I have a list like that:

private List myList = new ArrayList();

I want to get the .class of T. How can I do that?

4条回答
  •  孤独总比滥情好
    2021-01-18 02:09

    You cannot. That information is not available at runtime. If your list isn't empty you might be able to get away with checking the class of the first element.

提交回复
热议问题