0

I have an array list of:

ArrayList<ItemsBean> itemsList1 = new ArrayList<ItemsBean>();

I called the data from data base and added to this Arraylist

while (items.next()) {
    ItemsBean bean = new ItemsBean();
    bean.setInvNo(items.getString("Invoice_Number"));
    bean.setItemnNameDisplay(items.getString("Prodname"));
    bean.setParentobjectid(items.getString("ParentObjectID"));

    bean.setQuantityDisplay(items.getInt("Quantity"));
    bean.setProdnum(items.getInt("ProdNum"));

    itemsList1.add(bean);
}

Now I have new array list:

ArrayList<ItemsBean> newListitems2 = new ArrayList<ItemsBean>();

now I want to pass same data to this new array list in same activity

0

2 Answers 2

1

You can either use addAll() or try like this arraylist2 = arraylist1 .

addAll() is like below

arraylist2.addAll(arraylist1);

Hope this is helpful :)

Sign up to request clarification or add additional context in comments.

Comments

0

ArrayList newListitems2 = new ArrayList(itemsList1); ArrayList has constructor, receiving Iterable<> as argument, so you cancreate new list with values from another list. Notice, values will remain the same, ArrayList only contains references to actual objects.

1 Comment

@joy how is it "no use"? This answer appears to me to be the correct answer. (Possibly with a necessary correction: ArrayList<ItemsBean> newListitems2 = new ArrayList<>(itemsList1).)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.