-3

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

2
  • we need to see your BuyingDo class Commented Apr 26, 2012 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. Commented Apr 26, 2012 at 15:56

1 Answer 1

0

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.