P.Ambh P.Ambh - 1 year ago 86
Java Question

How to populate a collection in java?

Suppose we are creating a class in java where name and code are two private members and then are passing them in the list.

class A
private int code;
private string name;
public getCode()
{ return code;}
public setCode(int code){this.code=code;}
public getName()
{ return name;}
public setName(String name){this.name=name;}

class B {
List<A> l1=new List<A>

Now how to populate list A?

Answer Source
A obj = new A();

List<A> list = new ArrayList<>();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download