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

The Archive Base Latest Questions

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

I would like to know how to create a structure to hold three lists

  • 0

I would like to know how to create a structure to hold three lists in the following format:

[[[x],[y]],[z]]

with x,y,z being three lists of strings.

Note that I want to have the x and y lists on the 3rd level down and the z list on the 2nd level down.

I have tried creating 3 separate arraylists for x,y and z then another arraylist that holds x and y. The problem arise when I tried to create the outer most arraylist to hold all three, because something like

ArrayList<ArrayList<ArrayList<String>>> outerList = new ArrayList<ArrayList<ArrayList<String>>>();

would work for x and y but wont work for z because z is only 2 levels down.

I understand what I’m trying to do is more like a tree but I do not know how to implement a non-binary tree in java (x,y,z having more then just 2 branches).

What I’m trying to get out of this is a way to assign weights eg. user inputs a term, I iterate first through all the child nodes (x,y,z) and try to find it. If I find it I assign a high weight, otherwise I try to find it in the parent nodes (the list that holds x,y) and give it a moderate weight else I search in the root node and assign a minimum weight. The structure described is simply the relationship between the terms that I have categorized.

Any ideas on how to do this?

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

    The structure is easy enough to make, but working with it will be really ugly because you don’t know how deep it goes. If this is a set structure, where you only ever have x, y, and z, you should make a custom object to handle that known structure. If you won’t know the structure until runtime, then you need something like this.

    Note that while this structure does match what you asked for, I don’t necessarily recommend using it unless you have to. Look for alternatives. You mentioned a tree, but from your structure this would be a tree with data only at the leaf nodes, so keep that in mind if/when you implement it.

    public void useArrayList()
    {
        ArrayList<ArrayList<?>> weirdStructure = new ArrayList<ArrayList<?>>();
        ArrayList<String> x = new ArrayList<String>();
        ArrayList<String> y = new ArrayList<String>();
        ArrayList<String> z = new ArrayList<String>();          
        ArrayList<ArrayList<String>> xy = new ArrayList<ArrayList<String>>(); 
        xy.add(x);
        xy.add(y);
        weirdStructure.add(xy);     
        weirdStructure.add(z);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know how to create a php function that can be
I'd like to know how one would create an application that starts in the
I would like to know How to create a fps-game with SDL lib? Are
I would like to know a way to create an XML file using MySQL
I would like to know if there is a way to take create a
I would like to create a multi-dimensional array with two variables but don't know
I would like to know whether there are software that a user can edit
I would like to know What are the difference between folder-structure and package used
we would like to know, How to create Vertical Navigation Menu in Wordpress. I
I would like to know what is the structure of the object the function

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.