android - how to get data(name=“string”) from Arraylist in java? -


i'm trying data arraylist name=telugu. don't know do. please 1 this.

my code is(in jsp page):

try{     string lang=request.getparameter("languages");     out.println("know languages are:"+lang); }catch(exception e){     e.printstacktrace(); } 

above languages parameter containe data:

[namedfacebooktype[id=107617475934611 metadata=null name=telugu type=null], namedfacebooktype[id=112969428713061 metadata=null name=hindi type=null], namedfacebooktype[id=106059522759137 metadata=null name=english type=null]] 

i want display know languages are:

telugu hindhi english 

any 1 thank you.

from output looks "request.getparameter("languages")" returns collection of objects of type "namedfacebooktype".

you need type cast output of "request.getparameter("languages")" collection type (or interface/parent class). ie.

list<namedfacebooktype> 

you need iterate collection , use appropriate getter method on namedfacebooktype retrieve value of "name" field.

the code :

 object o = request.getparameter("languages");  if(o instanceof list<?>){     list<namedfacebooktype > list = (list<namedfacebooktype>) o;     string []names = new string[list.size()];     int i=0;     for(namedfacebooktype namedfacebooktype : list){         names[i]=namedfacebooktype.getname();         i++;     }      for(string name:names){         system.out.println(name);     } } 

currently looks output object's (collection) tostring() method invoked assigning value string object. hence output.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -