Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6835971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:17:52+00:00 2026-05-26T23:17:52+00:00

As per the requirement, I have parsed an XML file and set data into

  • 0

As per the requirement, I have parsed an XML file and set data into these two DTO classes:

public class DetailsDTO implements java.io.Serializable {
private String      userid;
private String      accountnum;
private Customer    customer;
// setters and getters

public class Customer implements Serializable
{
private String            street;
private String            country;
// setters and getters

After adding data of the Customer class to DetailsDTO, I added this DetailsDTO to an ArrayList as shown:

List list = new ArrayList();
// and added these DetailsDTO class to an ArrayList
list.add(detailsDTO)

Now there is a Master DTO called as WholeDetails which consists of all variables defined in various DTO classes as shown.

class WholeDetails
{
private String   userid;
private String   accountnum;
private String   street;
private String   country;
}

Now, as you see, all the data is aviable within the ArrayList.

How can I extract the contents from ArrayList and map it to the WholeDetails?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:17:52+00:00Added an answer on May 26, 2026 at 11:17 pm

    You will have to do the mapping e.g.

    List<DetailsDTO> list = new ArrayList<DetailsDTO>();    
    // and added these DetailsDTO class to an ArrayList   
    list.add(detailsDTO);  
    
    List<WholeDetails> wholeDTOList = new ArrayList<WholeDetails>();   
    for(DetailsDTO dto:list){  
      WholeDetails whole = new WholeDetails();  
      whole.setUserid(dto.getUserid());  
      whole.setAccountNum(dto.getAccountNum());  
      whole.setStreet(dto.getCustomer().getStreet());  
      whole.setCountry(dto.getCustomer().getCountry());  
      wholeDTOList.add(whole);
    
    }   
    

    If you like it to be more short you could create an adapter class that maps the DetailsDTO to the WholeDetailsDTO and add the result object to the list

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xml file. As per my requirement I need to update empty
As per clients requirement, i have added a background music to webpage. I have
I have a class (in C++), call it Data , that has thousands of
I have all my ResourceBundle values in a table and formatted as per requirement.
I have the below jquery code I have customized it as per my requirement
I have modified a SharePoint visual studio workflow which works as per requirement on
I have an requirement as per which I have to call an existing java
I am using SQLite C# library and as per my requirement, before going to
I'm using RichFaces per a client requirement, but the markup it (and the stock
Per this helpful article I have confirmed I have a connection pool leak in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.