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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:06:18+00:00 2026-06-07T23:06:18+00:00

I have an ArrayList of HashMap elements that has a format of Category, Activity

  • 0

I have an ArrayList of HashMap elements that has a format of Category, Activity and Time. I.E.

{CATEGORY=Planning, ACTIVITY=Bills, TIME=5}
{CATEGORY=Planning, ACTIVITY=Bills, TIME=7}
{CATEGORY=Planning, ACTIVITY=Meetings, TIME=10}
{CATEGORY=Resources, ACTIVITY=Room1, TIME=15}
....

Take note of the CATEGORY/ACTIVITY pair that is repeated as that can happen in the List

I need to be able to convert this List into a multidimensional one. The best way I can think of for how this List needs to look is by writing some pseudocode…please see that at the bottom of the post.

I’ve thought of several different approaches on how to implement this but I’m quite frankly stuck and frustrated at how to do this. I’ve thought of taking the inefficient approach of looping through the ArrayList several times in outer and inner loops but I know that wouldn’t be good coding practice.

Any suggestions on how I can implement this conversion so I can loop like in the pseudocode below?

For CATEGORY in CATEGORIES {
    CategoryTime = 0
    Display Category Header
    For ACTIVITY in ACTIVITIES {
        Activity Time = 0
        For TIME_RECORD in ACTIVITY
            Add time to activity total time, category total time & grand total
        }
        Display Activity Total
    }
    Display Category Total
}
Display Grand Total and rest of information...

Edit
I appreciate all the feedback given for this problem and it appears that really the best way to go is to enhance a class that the ArrayList of HashMap elements is a member of.

I’ve put in a vote to close this question as has another person as it’s too localized. I would appreciate it if some of you other developers would follow suit to close the question. I would delete it but I can’t at this point because there are answers to the question.

  • 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-07T23:06:20+00:00Added an answer on June 7, 2026 at 11:06 pm

    I would write a class that looks like so:

    public class Planner  
    {    
       Map<Category, Collection<Planner>  details;  
       String activity;  
       long time;  
    
    }  
    
    public enum Category  
    {  
        PLANNING,RESOURCES,ETC;  
    }    
    

    Then you should be able to do the following:

    for(Category current: Planner.getDetails().keySet())  
    {  
        CategoryTime = 0  
        Display Category Header
        Activity Time = 0
        for(Planner currentPlanner : planner.getDetails().get(current))  
        {  
              currentPlanner.getActivity();  
              Activity Time += currentPlanner.getTime();
        }  
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a hashmap where every key has many values(stored in a arraylist). How
I have an ArrayList of HashMap like this: ArrayList<HashMap<String, String>> playListSongs = new ArrayList<HashMap<String,
I have the following ArrayList ArrayList<HashMap<String, String>> list; HashMap<String, String> map; with the following
I have a List of HashMap such as below ArrayList l = new ArrayList
I have an Arraylist of HashMap . Each HashMap element contains two columns: column
I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String,
I have roughly 420,000 elements that I need to store easily in a Set
I have a problem on arraylist and hashmap As according to my requirement, I
I have hashmap and its keys are like folder/1.txt,folder/2.txt,folder/3.txt and value has these text
I have created an application having tab activity which in turn has 5 different

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.