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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:56:36+00:00 2026-06-15T07:56:36+00:00

Hello everyone how can I do to initialize ArrayList<Record<T>> [] values; with a number

  • 0

Hello everyone how can I do to initialize

ArrayList<Record<T>> [] values;

with a number of rows and columns? for example, with three rows and four columns?

  • 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-15T07:56:38+00:00Added an answer on June 15, 2026 at 7:56 am

    Using an array of generic type (such as ArrayList<T>) is a way to hell. The following line doesn’t even compile:

    ArrayList<Record<T>>[] values = new ArrayList<Record<T>>[SIZE_ARRAY];
    

    The compiler issues this error:

    Cannot create a generic array of ArrayList<Record<T>>
    

    The only sensible solution is to create a list of lists:

    // create matrix
    ArrayList<ArrayList<Record<T>>> matrix = new ArrayList<ArrayList<Record<T>>>();
    
    // add 3 rows:
    for (int i = 0; i < 3; i++) {
        ArrayList<Record<T>> row = new ArrayList<Record<T>>();
        matrix.add(row);
    
        // add 4 elements to each row
        for (int j = 0; j < 4; j++) {
            Record<T> record = ... // get the record
            row.add(record);
        }
    }
    

    And now you can access the element at [2][3] (last element of the last row):

    Record<T> record = matrix.get(2).get(3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everyone how can I get two values from different select boxes? I get
Hello everyone How can I get the difference between a number and the next
Hello everyone I am getting this exception: The magic number in GZip header is
hello everyone I'm working with Eclipse under Windows XP, but I can't find there
hello everyone I'm trying to write function which can unfold int in the list
Hello everyone i am trying to format the input number range with php number_format
Hello everyone I have a code and I want to find the number of
Hello everyone my menu bar can't fit into my <div> area at different browser.
Hello everyone I have two login but how can I assign these login URLs
Hello everyone I have used [Authorize] but when redirect to login view I can

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.