ArrayList to Array of Strings in java

前端 未结 5 1673
一向
一向 2021-02-05 11:53
ArrayList newArray = new ArrayList();
newArray = urlList.getUrl();
for( int i = 0 ; i < newArray.size();i++)
{
    System.out.println(newA         


        
5条回答
  •  隐瞒了意图╮
    2021-02-05 12:13

    The first option is better as it allows you to pass in a typed array, which is then populated inside the method.

    The second option returns an Object[] - so you would have to cast it to use String methods.

提交回复
热议问题