How to add an object to an ArrayList in Java

前端 未结 5 600
有刺的猬
有刺的猬 2020-12-07 15:55

I want to add an object to an ArrayList, but each time I add a new object to an ArrayList with 3 attributes: objt(name, address, contact)

5条回答
  •  醉酒成梦
    2020-12-07 16:50

    You have to use new operator here to instantiate. For example:

    Contacts.add(new Data(name, address, contact));
    

提交回复
热议问题