Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Add value to a list

Posted on 2013-06-14
2
Medium Priority
?
242 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …
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…
Suggested Courses

610 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