java - How to add number of String values to an ArrayList? -


i have scenario wherein have bean class i'm getting client names , other client related details. i'm creating bean object , getting details.

arraylist<clientbean> clientlist = (arraylist<clientbean>) (new queriesdao())                 .getallclient(); 

from above code getting details of client. , client names i'm through index form,

clientbean clist = clientlist.get(2);            (clientbean clientbean : clientlist) {         clientbean.getclientname(); // here i'm getting client names 1 one.            }    

my question how add client names in arraylist dynamically?

generally add values list (so arraylist) can use methods:

please check documentation (linked on answer) details on each method.


to add client names list (i assumed name string, change type)

list<string> names = new arraylist<string>(); (clientbean clientbean : clientlist) {     names.add(clientbean.getclientname()); } // here names list requested names 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -