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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:36:48+00:00 2026-05-30T00:36:48+00:00

I have been looking through the Java Tutorials at the Interfaces tutorial, specifically on

  • 0

I have been looking through the Java Tutorials at the Interfaces tutorial, specifically on Collections (Set, List, Queue, etc.) and I came across the fact that a Set cannot contain duplicates in its elements.

My problem is the fact that I do not fully understand how to create a set of a multi-dimensional array of an unknown size.

In order to fill the multi-dimensional array, I will be placing 1’s and 0’s inside of an array so that each one will look like the following: (if it fits the criteria I am looking for)

[ 0  1  1  0
  0  1  1  0
  0  1  0  0
  0  1  0  0
  0  0  0  0 ]

Or something of that nature. I would like to think this can be accomplished through declaring an multi-dimensional array like:

int[][] array = new int[5][];

Yet I cannot understand how that would work with filling multiple array elements or how to accomplish this with a set.

Please let me know if this is not clear enough.

  • 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-30T00:36:49+00:00Added an answer on May 30, 2026 at 12:36 am

    List’s can contain duplicates, sets cannot. You can declare a (dynamic) multidimensional structure in several ways, heres one:

    List<List<Integer>> multiDimensional = new ArrayList<List<Integer>>();
    List<Integer> row = Arrays.asList({0, 1, 1, 0});
    multiDimensional.add(row);
    

    And so on and so forth. To access the elements of the list utilize the get method in a way similar to what you would do with arrays:

    Integer someVal = multiDimensional.get(0).get(3);
    

    Having said that, you only need to use this nested List setup if your multidimensional structure needs to be 100% dynamic, aka you need the ability to grow the rows and columns constantly throughout the execution of your logic. You can actually use an ordinary array for your multidimensional structure, assuming that the number of rows can be determined ahead of time, and that each row’s length will not change after that row has been initialized. Case in point:

    int[][] multiDimensional = null;
    
    int rows = ... ;// Determine number of rows
    multiDimensional = new int[rows][];
    
    for(final int[] row: multiDimensional) {
        final int cols = ...; // Determine number of cols for this row
        row = new int[cols];
    }
    

    And you access the elements with your usual array semantics (multiDimensional[0][3]).

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

Sidebar

Related Questions

I have been looking through Scott Guthrie's MVC tutorials and it seems like the
I've been looking through the Java API, but have had no luck in working
I am new to java and have been looking at few tutorials around GIS
I have been looking through code for the last 3 days, and the original
I have been looking through some code on an open source project recently and
I am interested in using a DataObject and have been looking through the documentation.
I have been looking for a good Java web framework and found Tapestry, which
I have been looking through Adobe's File Format Specification for PSD (Photoshop files) and
I have been looking for an answer for how to execute a java jar
Have been looking at the MVC storefront and see that IQueryable is returned from

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.