Here is my declaration: SelectedAsset selectedAsset[]= null; Collection selectedAssetsCollection; in the method I am calling follwing code. selectedAsset = new SelectedAsset[selectedAssetsCollection.size()]; selectedAsset=(SelectedAsset[])selectedAssetsCollection.toArray(); when I checked selectedAssetsCollection.size() returns me size 1. But it gives me classcast exception, while it contains object of type SelectedAsset. I wonder for this awkword behave with toArray method.