java - To separate Integer and String ArrayList from Object ArrayList -
i have arraylist containing objects. have 2 different arraylists, 1 containing strings , other integers. need strings , integers rom parent list , put in new 2 arraylists. arraylists follows.
arraylist<object> ldeltaattrlist = new arraylist<object>(); arraylist<string> ldeltaattrliststring = new arraylist<string>(); arraylist<integer> ldeltaattrlistinteger = new arraylist<integer>();
please help.
you check if object whether string or integer , put in right list.
for(object o : ldeltaattrlist) { if(o instanceof string) { ldeltaattrliststring.add(o); } else if(o instanceof integer) { ldeltaattrlistinteger.add(o); } }
Comments
Post a Comment