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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:48:02+00:00 2026-06-16T03:48:02+00:00

I have four arrays of strings and I would like to create a two

  • 0

I have four arrays of strings and I would like to create a two dimensional array of 3 columns and dynamic rows.

the arrays are like:

String[] first_name;
String[] last_name;
String[] unit;
String[] phone_number;


Object[][] obj = new Object[first_name.length()][3]

My problem is how do I achieve something like this:

obj = {first_name[index] + " " + last_name[index], unit[index], phone_number[index]}

Please help out!!!

  • 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-16T03:48:04+00:00Added an answer on June 16, 2026 at 3:48 am

    I am assuming that by dynamic rows you mean that it depends on the number of elements in the first_name array.

    So you could simply iterate:

    String[][]obj = new String[first_name.length][3];
    
    for (int i = 0; i < first_name.length; i++)
    {
      obj[i][0] = first_name[i] + " " + last_name[i];
      obj[i][1] = unit[i];
      obj[i][2] = phone_number[i];
    }
    

    However, this approach is not very good. You should consider creating an object for example named Employee which as the 3 fields, and then you just have an array of Employee

    For example:

    public class Employee
    {
      String name;
      String unit;
      String phoneNumber;
    
      public Employee(String name, String unit, String phoneNumber)
      {
         //... rest of constructor to copy the fields
      }
    
      //... setters and getters
    }
    

    And then you just have:

    Employee[] employees = new Employee[first_name.length];
    
    for (int i = 0; i < first_name.length; i++)
    {
       employees[i] = new Employee(first_name[i] + " " + last_name[i], unit[i], phone_number[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two-dimensional char array declared with four strings. private static string string1
If I have the following array of strings: string[] stringArray = {"one", "two", "three",
How can I store arrays in single array? e.g. I have four different arrays,
I will be short, what i have is array=( one.a two.b tree.c four.b five_b_abc)
i have four tables user-question contains two columns: questionID, userID, the questions that the
Lets say I have string like this: String q = foo (one) bla (two)
Ajax calls an array of four strings, I then want to print each string
I have four arrays(array1..4) each containing four strings e.g var array1 = ['array1item1', 'array1item2',
How would I split an inputted string such as one two three four five
I have a string like this. char array1[250] = {Array Values are %d,%d,%d,%d}; And

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.