Why I cannot add ArrayList directly to Jlist?

后端 未结 4 1597
野的像风
野的像风 2021-01-24 09:07

i am trying to add ArrayList to Jlist, but the only way that I given to understand is that to write the code like this :

ArrayList labels = new Arr         


        
4条回答
  •  不要未来只要你来
    2021-01-24 09:52

    Because JList doesn't have a constructor that accepts an ArrayList (or a List). It can only accept an array, a ListModel, or a Vector. See the documentation.

    An ArrayList is not an array. You can't pass an ArrayList to a method that wants an array.

提交回复
热议问题