Solved

Add value to a list

Posted on 2013-06-14
2
238 Views
Last Modified: 2013-06-17
How would I write a statement to add the value to the list.


    public ItemVO getItems (List<ItemVO > XItems, String
                                            test
      {
          List<ItemVO> resultList;
            
          for (ItemVO vo : XItems)
          {
               If vo.getName = test
              {
                // add vo to resultList  HOW WOULD I write this statement to add to list
              }  
          }  
 
            return resultList;
      }
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 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39249243
You need to instantiate your list first of all:

List<ItemVO> resultList = new ArrayList<ItemVO>();

Open in new window


Then it would be a matter of calling the add method.

e.g.

if (vo.getName == test)
{
    resultList.add(vo);
}   

Open in new window

0
 
LVL 21

Expert Comment

by:Amitkumar Panchal
ID: 39250131
Agree with kaufmed
0

Featured Post

Technology Partners: 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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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.
Suggested Courses

739 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