Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

adding from 1 list to another list

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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

886 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