Solved

adding from 1 list to another list

Posted on 2013-06-24
2
312 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 76
countHi2 challenge 7 44
java set up 1 46
Checkbox and ListView in Android Layout 4 39
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now