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 6733839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:49:03+00:00 2026-05-26T10:49:03+00:00

I need to store a TDSContent into a hashmap specifying a String key. I

  • 0

I need to store a TDSContent into a hashmap specifying a String key. I need to do something like this.

public class Target {
    public Target() {
        final int a = 0x64c896;
        final int b = 0xc050be;
        final int c = 0xffc896;

        TDS = new HashMap<String, TDSContent>();

        TDSContent contentMA = new TDSContent(a, b, c, 10);
        TDSContent contentMB = new TDSContent(a, c, b, 10);
        TDSContent contentMC = new TDSContent(b, a, c, 10);
        TDSContent contentMD = new TDSContent(c, b, a, 10);
        TDSContent contentME = new TDSContent(c, a, b, 10);
        TDSContent contentMF = new TDSContent(b, c, a, 10);
        ... // and so on...

        TDS.put("Marker A", contentMA);
        TDS.put("Marker B", contentMB);
        TDS.put("Marker C", contentMC);
        TDS.put("Marker D", contentMD);
        TDS.put("Marker E", contentME);
        TDS.put("Marker F", contentMF);
            ... // and so on...
    }

    public int getCL(String key) {
        TDSContent tdc = TDS.get(key);

        if(tdc.equals(contentMA)) {
            return contentMA.getValue();
        } else if(tdc.equals(contentMB)) {
            return contentMB.getValue();
        } else if(tdc.equals(contentMC)) {
            return contentMC.getValue();
        } else if(tdc.equals(contentMD)) {
            return contentMD.getValue();
        } else if(tdc.equals(contentME)) {
            return contentME.getValue();
        } else if(tdc.equals(contentMF)) {
            return contentMF.getValue();
        } ...// and so on...

             else {
            return contentMD.getValue();
        }
    }
}

The problem is, it will take so much hard work to manually create an object of class TDSContent.

Can I do something like this …:

public class Target {
    public Target() {
        final int a = 0x64c896;
        final int b = 0xc050be;
        final int c = 0xffc896;

        TDS = new HashMap<String, TDSContent>();

           // form: new TDSContent(CL, CM, CR, D);
        TDS.put("Marker A", new TDSContent(a, b, c, 10));
        TDS.put("Marker B", new TDSContent(a, c, b, 10));
                ... // and so on..
    }

    public int getCL(String key) {
           // this method gets the first parameter of the TDSContent
           // constructor (see comment above).
        return TDS.get(key).getValue();
    }

    public int getCM(String key) {
    ... // similar to getCL but returns the second parameter of the TDSContent
        // constructor (see comment above)

… on getCL() and get and the instantiated[?] value of TDSContent?

Specifically, if I have a call on something like:

Target target = new Target();
int x1 = target.getCL("Marker A"); // I should get 0x64c896 here
int x2 = target.getCM("Marker A"); // I should get 0xc050be here

Is that possible?

  • 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-26T10:49:03+00:00Added an answer on May 26, 2026 at 10:49 am

    Certainly, just match the getXXX() method you call on the TDSContent object in the map to the accessor. This assumes you have accessors on TDSContent for each constructor argument.

    public int getCL(String key) {
        return TDS.get(key).getCL();
    }
    
    public int getCM(String key) {
        return TDS.get(key).getCM();
    }
    
    public int getCR(String key) {
        return TDS.get(key).getCR();
    }
    
    public int getD(String key) {
        return TDS.get(key).getD();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to store data in a grid like this: {0,1,2,3} {4,5,6,7} {8,9,10,11} {12,13,14,15}
I need to store a list of key value pairs of (integer, boolean) in
Need to store values from foreach loop into an array, need help doing that.
I need to store a list of 1 million key-value pairs in python. The
I need to get pointer to my class instance inside this instance. I can't
I need to store long strings in a database. the string may be 5
I need to store relative path of a document into a MySQL table. The
I need to store a double as a string. I know I can use
I need to store historical data for something in mysql (only last 7 days)
I need to store an encryption key that is going to be accessed through

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.