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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:32:11+00:00 2026-06-07T10:32:11+00:00

I am using multiple hashtables for a program viz table1 table2 table3 etc. Each

  • 0

I am using multiple hashtables for a program viz table1 table2 table3 etc. Each table has 3 key-value pairs. the keys are same with different values.
Now in the UI of my program i have a comobobox to pick the table name from user. Once it is selected i am storing it in a variable and would like to use this variable to open the appropriate table.

Thanks Eric Coolman for this piece which i have edited here for my query.

Hashtable table1 = new Hashtable();

table1 .put("COL1", Double.toString(dvalue1));
table1 .put("COL2", value2);
table1 .put("COL3", value3);

Hashtable table2 = new Hashtable();

table2 .put("COL1", Double.toString(dvalue4));
table2 .put("COL2", value5);
table2 .put("COL3", value6);

// reading that value back:

double dvalue1 = Double.parseDouble((String)table1.get("COL1"));
double value6= Double.parseDouble((String)table2.get("COL3"));`

here how can i use a variable instead of table1 and table2? what is the syntax. I am new to java.

  • 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-07T10:32:13+00:00Added an answer on June 7, 2026 at 10:32 am

    First of, your structure looks like you are in object denial: what you’ve got as Hashtable object should probably be objects of a custom type with 3 fields (col1, col2 and col3; or more readable versions of that).

    Next: you can simply use a third variable to switch on which object you read from:

    Hashtable readFromMe;
    if (someCondition)
      readFromMe=table1;
    else
      readFromMe=table2;
    
    Object o = readFromMe.get("COL3");
    

    This code would read from table1 if someCondition is true and from table2 otherwise.

    Also, a shorter version of the first 5 lines of the code above would be Hashtable readFromMe = someCondition ? table1 : table2;.

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

Sidebar

Related Questions

We have multiple tables that contain static key/value pairs, which are currently pulled using
Using Hashtable I want to have multiple objects mapped to the same key. E.g.
When using multiple inheritance C++ has to maintain several vtables which leads to having
Has anyone tried using multiple formatters ( UIViewPrintFormatter , UIMarkupTextPrintFormatter , UISimpleTextPrintFormatter ) with
I am using multiple NSTextViews inside a NSTableView. Each textView is added on the
I plan on using multiple popups on my website. Every popup will be rendered
I am using multiple instances of AVAudioPlayer to play multiple sound files in a
I am using multiple instances of AVAudioPlayer to play multiple audio files simultaneously. I
I am using multiple threads in my application using while(true) loop and now i
I'm using multiple threads in my application. Basically I have a combo box and

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.