且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用构造函数向 ArrayList 添加新对象

更新时间:2023-12-06 16:50:04

如果要将对象添加到数组列表中,创建你的类类型的数组列表,你可以像这样添加它,

If you want to add the objects to the arraylist, Create the arraylist of your class type and you can add it something like this,

   ArrayList<Phone> phoneList = new ArrayList<>();
   phoneList.add(new phone("id", "phoneNumber", "firstName", "lastName"));