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

  • SEARCH
  • Home
  • 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 8360439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:28:07+00:00 2026-06-09T11:28:07+00:00

I am passing two series of data ( colon sperated :) to a method

  • 0

I am passing two series of data ( colon sperated 🙂 to a method and expecting that to be set inside my Custom class CountryDTO

This is my CountryDTO class

public class CountryDTO {

    public CountryDTO(String a , String b , String c)
    {

    }
public String value1;
public String value2;
public String value3;

// setters and getters 

}



This is my Main class 

public class Test {

    public static void main(String args[]) throws Exception {

        Test test = new Test();
        List list = (List) test.extract("IND,US,UK : WI,PAK,AUS");

        Iterator itr = list.iterator();

        while (itr.hasNext()) {
            CountryDTO ind = (CountryDTO) itr.next();
            System.out.println(ind.getValue1());
        }
    }

    public List<CountryDTO> extract(final String v) throws Exception {
        String[] values = v.split(":");
        List<CountryDTO> l = new ArrayList<CountryDTO>();
        for (String s : values) {
            String[] vs = s.split(",");
            l.add(new CountryDTO(vs[0], vs[1], vs[2]));
        }
        return l;
    }
}

What is happening is that , i am getting output as null ( CountryDTO is not being set )

Could anyone please help me

  • 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-06-09T11:28:09+00:00Added an answer on June 9, 2026 at 11:28 am

    I’m sorry, but your DTO is incorrect. I think it should look like this:

    public class CountryDTO {
    
        private final String value1;
        private final String value2;
        private final String value3;
    
        public CountryDTO(String a , String b , String c) {
            this.value1 = ((a != null) ? a : "");
            this.value2 = ((b != null) ? b : "");
            this.value3 = ((c != null) ? c : "");
        }
    
        // just getters; no setters 
    
    }
    

    I can’t speak to what else you code might be doing wrong, but this is certainly off-base.

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

Sidebar

Related Questions

I'm creating a ListView that contains two TextViews and an ImageView. I'm passing data
This is driving me mad. I'm passing two variables into a function that posts
How do I go about passing two sets of Data to a view in
I have this code below. As you can see I am passing two variables
I have an IF statement that consists of two separate function calls passing values
I was wondering what is the best practice re. passing (another class) amongst two
I have a (C#) genetic program that uses financial time-series data and it's currently
Possible Duplicate: Passing two command parameters using a WPF binding I need that send
Object A calls method M of object B , passing it two callbacks for
I have two database tables. One table stores data for a commitment that a

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.