2

I have a twinColSelect and i m populating this from database. I need to access its selected items. I tried below the code but it didn't worked. How can i do that ?

ArrayList<String> systemNames = new ArrayList<String>();
systemNames = (ArrayList<String>) twinColSelectSystem.getValue();

for (int i=0;i<systemNames.size();i++)
System.out.println(systemNames.get(i));
Ruslan Ostafiichuk
  • 4,422
  • 6
  • 30
  • 35
developerCoder
  • 176
  • 5
  • 16

2 Answers2

1

Try this:

ArrayList<String> systemNames =
    new ArrayList<String>((Set<String>) twinColSelectSystem.getValue());
Krayo
  • 2,492
  • 4
  • 27
  • 45
  • Throwable occurred: java.lang.ClassCastException: java.util.Collections$UnmodifiableSet incompatible with java.util.ArrayList – developerCoder Dec 05 '14 at 13:10
1

Try this:

    ArrayList<String> systemNames = new ArrayList<String>();
    systemNames.addAll((Set<String>) twinColSelectSystem.getValue());
Ruslan Ostafiichuk
  • 4,422
  • 6
  • 30
  • 35