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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:23:39+00:00 2026-05-26T16:23:39+00:00

In Java, how can I create an array where each element is a list

  • 0

In Java, how can I create an array where each element is a list of objects containing a pair of keys.

Then given an index of this array, I should be able to search the list at the index provided a single key value and retrieve the corresponding value.

Problem Statement

I have around 2 million webpage name and corresponding to each name are categories (one or more) .

I can hash them down to say 1,00,000 using some hash function but obviously their will be collisions.

I want to build a data structure in Java that can store all this information, and then given a webpage and then, after hashing, given the index, I can find the categories of the web page.

  • 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-26T16:23:40+00:00Added an answer on May 26, 2026 at 4:23 pm

    It sounds like what you want is an array of maps:

    List<Map<KeyType, ValueType>> myList = new ArrayList<Map<KeyType, ValueType>>();
    

    This is how you add a map:

    myList.add(new HashMap<KeyType, ValueType>());
    

    This is how you add value to the map at index i with key as key:

    myList.get(i).put(key, value);
    

    To search for key in the map at index i use:

    ValueType value = myList.get(i).get(key);
    

    Edit: After your edit I think that the solution to your problem is to simply use HashMap<String, List<String>>. You’d use the name of the webpage as key and the list of category-names as values. There is no need to implement your own hash-map (it sounds like that was what you were doing).

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

Sidebar

Related Questions

I know in java you can create an array or list(honestly I forget which
In Java can I create a URI for a file located locally in the
How can I create a barcode image in Java? I need something that will
We can't use java.text.SimpleDateFormat, so is there any way to create date object from
What is the maximum file size 32 bit java can access? Is this architecture
In Java, you can create an enum as follows: public enum Letter { A,
[I have some code to create a JSON array. In this code I am
I have create following string multidimensional array in java. which has top outer array
I'm trying to create an array of 144 FloatBuffers so I can easily access
Is there anything simple Java can't do that can be done in a similar

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.