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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:40:36+00:00 2026-06-16T01:40:36+00:00

Sorry first time asking a question here. If I have a 2D Array like

  • 0

Sorry first time asking a question here.

If I have a 2D Array like this:

int[][] array2d = {{1, 2, 3}, {6, 7, 8}};

How do I add multiple 1D Arrays like this:

int[] array1d = {3, 2, 1};
int[] array1d2 = {8, 7, 6};

so that my original 2d array becomes this:

int[][] array2d = {{1, 2, 3}, {6, 7, 8}, {3, 2, 1}, {8, 7, 6}};

Note: this is for adding information from a JTextfield into a JTable whenever a button is pressed. So, the 2d array will be used as the data inside the table. If there is a better way to accomplish this I would appreciate it too. =)

  • 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-16T01:40:37+00:00Added an answer on June 16, 2026 at 1:40 am

    Your array :

    int[][] array2d = {{1, 2, 3}, {6, 7, 8}};
    

    is fixed in size, so you would have to create a copy with enough capacity to hold the new values:

    int[][] newArray = Arrays.copyOf(array2d, 4);
    newArray[2] = array1d;
    newArray[3] = array1d2;
    

    To add your data to the JTable the arrays would have to be first converted to a non-primitive type such as an Integer array. One option is to use the Apache Commons:

    model.addRow(ArrayUtils.toObject(array));
    

    for each row of the array.

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

Sidebar

Related Questions

Sorry, this's my first time to ask a question here. So, I don't have
I am first time asking question here, sorry, but I can not find similar
First time using this service for a question. I hope I am not asking
it's i first time i'm asking here. Sorry if the answer is available already.
Its my first time here and I don't know how to indent this sorry
I'm sorry that was my first time for asking question in stackoverflow. I just
Sorry this is obviously my first time here, I am just learning how to
Sorry for the kind of n00b question, but this is my first time dealing
The reason I am asking this question is because I have landed my first
this is my first time posting a question here - I've searched for ones

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.