Link to home
Start Free TrialLog in
Avatar of Zolf
ZolfFlag for United Arab Emirates

asked on

List of object

Hello there,

can somebody help me to put the order into the Order object.i get error
Type mismatch: cannot convert from List<Order> to Order

@Override
	public void saveOrder(List<Order> order)
	{
		// TODO Auto-generated method stub
		System.out.println(" list Size  "+order.size());
		
		List<NameValuePair> params = new ArrayList<NameValuePair>(order.size());
		
		params.add(new BasicNameValuePair("action", "save_order"));
		
		for(int i=0;i<order.size();i++)
		{
			Order order2 = order;
			System.out.println(" inside FOR " +order2.getCustomerID() +"  "+order2.getProductID()+"  "+order2.getQty());
			
			params.add(new BasicNameValuePair("amount_"+i, Integer.toString(order2.getQty())));
			params.add(new BasicNameValuePair("prod_id_"+i, Integer.toString(order2.getQty())));
		}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ksivananth
ksivananth
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
for(Order order2 : order)		{
System.out.println(" inside FOR " +order2.getCustomerID() +"  "+order2.getProductID()+"  "+order2.getQty());
			
params.add(new BasicNameValuePair("amount_"+i, Integer.toString(order2.getQty())));
params.add(new BasicNameValuePair("prod_id_"+i, Integer.toString(order2.getQty())));
		} 

Open in new window

SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial