Solved

adding from 1 list to another list

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
type mismatch (Object[] to double[] 4 33
servlet example 17 53
pagenation logic how it is working in my code 1 56
java mysql insert application 14 29
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

830 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