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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:25:17+00:00 2026-05-31T07:25:17+00:00

I am creating Dictionary and an ArrayList such as this. Dictionary testDict, testDict2 =

  • 0

I am creating Dictionary and an ArrayList such as this.

Dictionary testDict, testDict2 = null;
ArrayList al = new ArrayList();

testDict.put ("key1", dataVar1);
testDict.put ("key2", dataVar2);
testDict2.put ("key1", dataVar1);
testDict2.put ("key2", dataVar2);

al.add(testDict);
al.add(testDict2);

now my issue here is, how can I access the data within the dictionaries? Like for example how would I retrieve key1 from testDict using al?

Many thanks in advance 🙂

  • 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-31T07:25:18+00:00Added an answer on May 31, 2026 at 7:25 am

    As you can read in the Java Docs all Dictionary objects (note that e.g. Hashtable is one of them) have a method Object get(Object key) to access it’s elements. In your example you could access the value of the entry key1 in textDict like that:

    // first access testDict at index 0 in the ArrayList al 
    // and then it's element with key "key1"
    al.get(0).get("key1");
    

    Note, that you nowhere initialize your Dictionary objects and that the Dictionary class is abstract. So you could for example use a Hashtable (or if you don’t need synchronized access use a faster HashMap instead) for your purpose like this:

    testDict = new Hashtable<String, String>();
    

    And make sure to use the correct generic types (the second one has to be the type that your dataVars have)

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

Sidebar

Related Questions

I'm a new developer creating a simple dictionary app for personal use and my
I'm putting around 4 million different keys into a Python dictionary. Creating this dictionary
I'm creating a dictionary object in javascript (eg associate array) var myobj = {
I'm creating a dictionary app. My Sqlite database is about 15MB and on the
Is there some kind of a shorthand fluent interface for creating a parameters dictionary
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
When creating a new service in a WCF service project, Visual Studio will automatically
I'm creating a dictionary database using php and MySQL. The user can search for
This method doesn't work...but when I move away from returning a dictionary object and
I am creating dictionary out of a large file. def make_dic(): big_dic={} for foo

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.