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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:09:46+00:00 2026-05-22T18:09:46+00:00

I would like to create an array (enum) of array (enum) of array (enum)

  • 0

I would like to create an array (enum) of array (enum) of array (enum) of Strings. I don’t think it is possible to achieve this in Java, but I have heard about EnumMap.

public class Tricky {

    public enum enumA { A1, A2, A3 };
    public enum enumB { B1, B2, B3 };
    public enum enumC { C1, C2, C3 };

    HashMap<EnumMap<enumA, EnumMap<enumB, enumC>>,String> item
        = new HashMap<EnumMap<enumA, EnumMap<enumB, enumC>>,String>();

    public Tricky() {

        // How do I put and get strings in my hash map?


    }
}

The above code compiles, but how can I put and get string items in my map?

  • 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-22T18:09:47+00:00Added an answer on May 22, 2026 at 6:09 pm

    you might find this useful:

    package p;
    enum enumA {
        A1,A2,A3;
    }
    enum enumB {
        B1,B2,B3;
    }
    enum enumC {
        C1,C2,C3;
    }
    class MyArray{
        MyArray(Class<? extends Enum> e1,Class<? extends Enum> e2,Class<? extends Enum> e3) {
            strings=new String[e1.getEnumConstants().length][e1.getEnumConstants().length][e2.getEnumConstants().length];
            e3.getEnumConstants();
        }
        void set(enumA a,enumB b,enumC c,String string) {
            strings[a.ordinal()][b.ordinal()][c.ordinal()]=string;
        }
        String get(enumA a,enumB b,enumC c) {
            return strings[a.ordinal()][b.ordinal()][c.ordinal()];
        }
        public String toString() {
            StringBuffer sb=new StringBuffer();
            for(enumA a:enumA.values())
                for(enumB b:enumB.values()) {
                    for(enumC c:enumC.values()) {
                        sb.append(get(a,b,c));
                        sb.append('\n');
                    }
                    sb.append('\n');
                }
            return sb.toString();
        }
        public static void main(String[] arguments) {
            MyArray myArray=new MyArray(enumA.class,enumB.class,enumC.class);
            for(enumA a:enumA.values())
                for(enumB b:enumB.values())
                    for(enumC c:enumC.values())
                        myArray.set(a,b,c,""+a+b+c);
            System.out.println(myArray);
        }
        final String[][][] strings;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a multi-dimensional array with two variables but don't know
I would like to create an array (in php) from sql results like this:
I have an array X of 10 elements. I would like to create a
I have a JSON file that I would like to create an multi-dimensional array
I have a JSON file that I would like to create an array from.
I would like to create an SSL connection for generic TCP communication. I think
I would like to create an application wide keyboard shortcut for a Java Swing
I would like to create a two dimensional numpy array of arrays that has
i have a table called horse, i would like to create a form to
i have a table called horse, i would like to create a form to

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.