Solved

adding from 1 list to another list

Posted on 2013-06-24
2
324 Views
Last Modified: 2013-06-24
Two lists are passed to this method one list has items  and one list is empty.

I want to populate List B with List A.
 How  do I declare and reference LISTA and LISTB to populate from A to B?

public List<ItemVO>  getLow(List<ItemVO> ListA, List<ItemVO> ListB)

  for ( loop through List A)
    if ListA.getStatus = "LOW"
       add to ListB
   return ListB
0
Comment
Question by:cookiejar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Valeri earned 500 total points
ID: 39273145
if you want to populate all from A to B, then invoke ListB.addAll(ListA);

if you want to copy only some of the values, call this:

public List<ItemVO>  getLow(List<ItemVO> ListA, List<ItemVO> ListB) {
for (ItemVO item : ListA) {
  if (item.getStatus.equals("LOW")) ListB.add(item);
}
return ListB;
}
0
 

Author Closing Comment

by:cookiejar
ID: 39273481
Thank you, just what I need.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb mdb examples 1 39
dao vs facade design patterns 2 76
Coding for the first time 9 104
Is there a Google Voice API? 9 75
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question