To separate Integer and String ArrayList from Object ArrayList

I have an arraylist containing Objects. I have two different arraylists, one containing strings and the other integers. Now I need to get the strings and integers rom the parent list and put it in the new two arraylists. The arraylists are as follows.

ArrayList<Object> lDeltaAttrList = new ArrayList<Object>();
ArrayList<String> lDeltaAttrListString = new ArrayList<String>();
ArrayList<Integer> lDeltaAttrListInteger = new ArrayList<Integer>();

Please help.

Answers


You simply check if the Object is whether a String or an Integer and put it in the right list.

for(Object o : lDeltaAttrList) {
    if(o instanceof String) {
        lDeltaAttrListString.add(o);
    } else if(o instanceof Integer) {
        lDeltaAttrListInteger.add(o);
    }
}

Need Your Help

Get all folders of a publication using Core Service

tridion tridion-2011

Using Tridion Core Service how can we get existing folders of a particular publication. I am using SessionAwareCoreService2010Client class to create folders but could not locate in above class a pr...

Relative URL to a sub-directory

url hyperlink anchor relative subdirectory

For example, if currently I am on a webpage

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.