Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

adding from 1 list to another list

Posted on 2013-06-24
2
Medium Priority
?
338 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 2000 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

Independent Software Vendors: 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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

688 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