My question is specific to Java. I have a Get and Set method that will get and set the data.
I would like to add this into an arraylist. How can I do this ?
Below I’ve shown a small sample of what I’ve done so far.
public class GetSetMethod {
String newcompanyid = null;
public String getNewcompanyid() {
return newcompanyid;
}
public void setNewcompanyid(String newcompanyid) {
this.newcompanyid = newcompanyid;
}
}
In my MainActivity I am using this object
public class MainActivity{
ArrayList<String> bulk = new ArrayList<String>();
GetSetMethod objSample = new GetSetMethod();
objSample.setNewcompanyid(newcompanyid);
}
How can I put the values of objSample into the array list. I’ve tried using
bulk.add(newcompanyid);
But since I’ve a large amount of data to be passed (and there is a for loop also), it calls the function many times.
Thanks for your help !
1 Answer