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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:55:12+00:00 2026-06-13T20:55:12+00:00

I have (at least) two multidimensional String arrays (with UNequal dimensions), that I am

  • 0

I have (at least) two multidimensional String arrays (with UNequal dimensions), that I am trying to put side by side. That is,

String[][] arrayOne contains the following:

aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa

…and String[][] arrayTwo contains the following:

bbbbbbbb
bbbbbbbb
bbbbbbbb
bbbbbbbb

…and String[][] arrayThree contains the following:

ccccccc
ccccccc
ccccccc
ccccccc
ccccccc
ccccccc
ccccccc
ccccccc

What I have been unsuccessfully trying to do is create a method which returns the following (preferrably as a multidimensional String array, but as a String works too):

String[][] result contains the following:

               ccccccc
               ccccccc
aaaaa          ccccccc
aaaaa          ccccccc
aaaaa          ccccccc
aaaaa bbbbbbbb ccccccc
aaaaa bbbbbbbb ccccccc
aaaaa bbbbbbbb ccccccc
aaaaa bbbbbbbb ccccccc

So basically, the method would put the arrays side-by-side, align them all to the bottom, and combine them into one array.

So far, my complex attempts to solve this problem have only created more errors, and trying to debug with println statements and the like has only confused me more. And I figured someone mush known a fairly easy way to accomplish this task.

If anyone knows, your help would be greatly appreciated!!!

*EDIT – * Example #2:

aaaa            bbb            ccccc                       ccccc
aaaa   'plus'   bbb   'plus'   ccccc   'yields'   aaaa     ccccc
aaaa                           ccccc              aaaa bbb ccccc
                               ccccc              aaaa bbb ccccc
  • 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-13T20:55:13+00:00Added an answer on June 13, 2026 at 8:55 pm

    An (untested) general solution to your problem:

    EDIT: Thanks you @Paul Bellora for testing and confirming.

    public static <T> T[][] mergeArrays(Class<T> clazz, T[][]... arrays) {
        // determine length of 1st dimension.
        int dim1 = 0;
        for (T[][] arr : arrays) {
            dim1 += arr.length;
        }
        // Create new 2Dim Array
        T[][] result = (T[][]) Array.newInstance(clazz, dim1, 0);
        // Fill the new array with all 'old' arrays
        int index = 0;
        for (T[][] arr : arrays) {
            for (T[] array : arr) {
                // changes within your old arrays will reflect to merged one
                result[index++] = array;
            }
        }
        return result;
    }
    

    This is how you call it:

        String[][] one = // your 1st array here;
        String[][] two = // your 2nd array here;
        String[][] three = // your 3rd array here;
        String[][] four = // your 4th array here;
        // This works with an arbitrary amount of arrays.
        String[][] merged1 = mergeArrays(String.class, one, two, three);
        String[][] merged2 = mergeArrays(String.class, one, two, three, four);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with (at least) the following two fields: country club The
I have two checkboxes. I need to check that at least one of them
I am trying to get at least three words separated by two commas.I have
I have at least two arrays (actually four+): $first_names = array( '0' => 'Jon'
I have a git workflow that involves at least two branches, master and staging.
I have two multidimensional arrays like: [a] [b] [c] and [a] [b] [c] [d]
I have at least two different classes like following : //NOTE : these two
i have (at least) two addins installed in Visual Studio (2010 (Professional)). i would
Lets say i have at least two lua script files. test1.lua test2.lua both define
I have a winforms datagridview that seems to always have at least one row

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.