Solved

Add value to a list

Posted on 2013-06-14
2
230 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
2 Comments
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
Comment Utility
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 20

Expert Comment

by:Amitkumar Panchal
Comment Utility
Agree with kaufmed
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
count8 challlenge 13 84
computer science syllabus 3 52
firstChar challenge 13 83
base64 decode encode 12 96
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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

744 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

15 Experts available now in Live!

Get 1:1 Help Now