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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:05:46+00:00 2026-06-01T17:05:46+00:00

So I have: ArrayList<ArrayList<String>> Which contains an x number of ArrayLists which contain another

  • 0

So I have:

ArrayList<ArrayList<String>> 

Which contains an x number of ArrayLists which contain another y number of Strings.. To demonstrate:

Index 0:
  String 1
  String 2
  String 3
Index 1:
  String 4
Index 2:
Index 3:
  String 5
  String 6

Where index refers to the array index containing a string.

How can I transform this into a 2D array which looks like:

{{String1, String2, String3},{String4}, {}, {String5, String6}}

Thank you so much.

  • 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-01T17:05:48+00:00Added an answer on June 1, 2026 at 5:05 pm
    String[][] array = new String[arrayList.size()][];
    for (int i = 0; i < arrayList.size(); i++) {
        ArrayList<String> row = arrayList.get(i);
        array[i] = row.toArray(new String[row.size()]);
    }
    

    where arrayList is your ArrayList<ArrayList<String>> (or any List<List<String>>, change the first line inside the for loop accordingly)

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

Sidebar

Related Questions

In my winform application, I have an arraylist containing a dynamic number of string
I have an ArrayList called account which contains Strings. I'm trying to write a
I have an ArrayList which contains duplicate values at diff diff index. for example
I have an ArrayList of strings, and I want to randomly change a string's
E.G. to create an ArrayList of Strings we have to do something like List<String>
I have an array of strings. How can I convert it to System.Collections.ArrayList?
I have an object in my Action class which contains an arraylist of objects
I have an ArrayList in Java, which contains Objects, these Objects are made of
I have 2 arraylists in my project, list1, and list2. (both contains 9 String
I created an ArrayList which contains KeyValuePair<string, string> objects. There are ListBoxes which I

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.