Adding to an ArrayList Java

后端 未结 7 1419
终归单人心
终归单人心 2020-11-28 12:24

I am a beginner to java, and need some help.

I am trying to convert an Abstract Data type Foo which is an associated list to an Arraylist of the strings B. How do yo

7条回答
  •  时光取名叫无心
    2020-11-28 13:12

    Instantiate a new ArrayList:

    List myList = new ArrayList();
    

    Iterate over your data structure (with a for loop, for instance, more details on your code would help.) and for each element (yourElement):

    myList.add(yourElement);
    

提交回复
热议问题