Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have vehicle data object returning string array .I want to convert or cast to Arraylist BuyingDo data object.I have ArrayList objectList

I am getting value like this

VehicleDo list[]=data.getList()

I am converting like this

objectList=(ArrayList<BuyingDo)list

but its not working can anybody tell how to do this

share|improve this question
2  
Give total code –  nagarajub Apr 26 '12 at 9:58
    
we need to see your BuyingDo class –  Th0rndike Apr 26 '12 at 10:00
    
I think the problem would be that these two classes would not be related. They must be an extension (extended) from one to the other for this to work. For example BuyingDo extends VehicleDo might be one way of the two. But you must put your complete code and the error/exception you get in order for someone to help. –  Hassan Apr 26 '12 at 15:56
add comment

1 Answer

up vote 0 down vote accepted

Your question is a bit... well... unclear.

I think you mean either this:

List<VehicleDO> realList = Arrays.asList(list);

Or this:

List<BuyingDO> realList = new ArrayList<BuyingDO>(list.length);
for (VehicleDO vdo : list){
    realList.add((BuyingDO)vdo);
}

Assuming of course that VehicleDO can be cast to BuyingDO.

Something like that?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.