Converting HashMap to ArrayList
collections, generics, java
Solution
You're trying to cast the collection of values to a single `ExceptionLifeCycleDataBean`.
You can very easily get the list though:
List<ExceptionLifeCycleDataBean> beans =
new ArrayList<ExceptionLifeCycleDataBean>(transitionHash.values());
Or to add to an existing collection, with:
cardholderDataRecords.addAll(transitionHash.values());
No casts necessary.
Problem
I just want to move the transitionHash map values into the cardholderDataRecords arraylist. ``` HashMap<String,ExceptionLifeCycleDataBean> transitionHash = new HashMap<String,ExceptionLifeCycleDataBean>(); ArrayList<ExceptionLifeCycleDataBean> cardholderDataRecords = new ArrayList<ExceptionLifeCycleDataBean>(); ``` i am doing as ``` cardholderDataRecords.add((ExceptionLifeCycleDataBean) transitionHash.values()); ``` It's throwing ``` java.lang.ClassCastException: java.util.HashMap$Values cannot be cast to com.reportss.bean.ExceptionLifeCycleDataBean ```