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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:12:29+00:00 2026-06-05T07:12:29+00:00

I have a C# method that use params modifier for a 2-dimentions array. ///

  • 0

I have a C# method that use “params” modifier for a 2-dimentions array.

/// <summary>
///   Combine vectors horizontally.
/// </summary>
/// 
public static T[] Concatenate<T>(params T[][] vectors)
{
    int size = 0;
    for (int i = 0; i < vectors.Length; i++)
        size += vectors[i].Length;

    T[] r = new T[size];

    int c = 0;
    for (int i = 0; i < vectors.Length; i++)
        for (int j = 0; j < vectors[i].Length; j++)
            r[c++] = vectors[i][j];

    return r;
}

I convert it to Java like this:

{
    int size = 0;
    for (int i = 0; i < vectors.length; i++)
    {
        size += vectors[i].;
    }

    T[] r =(T[]) Array.newInstance(vectors[0][0].getClass(), size);

    int c = 0;
    for (int i = 0; i < vectors.length; i++)
    {
        for (int j = 0; j < vectors[i].length; j++)
        {
                r[c++] = vectors[i][j];
        }
    }

    return r;
}

But it seems to be wrong. Solution doesn’t work.
Please someone tell me the right way.
Thanks a lot.

  • 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-05T07:12:30+00:00Added an answer on June 5, 2026 at 7:12 am

    In Java you use ... instead of params, as is explained here

    So you declare your method like this (note the loss of one []):

    public static T[] Concatenate<T>(T[]...vectors)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have this method: public static object CallMethod(Delegate method, params object[] args)
I have a method that I will use in the following contexts: 1. User
I have a method that I've started to use in multiple models for Webscraping,
I have a method that returns lot of data, should I use @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) for
I have a function that use setInterval() method to watch css propertie change('cause in
I have a program that makes use of the following method to get a
I have a service method that takes params as an input and creates a
In C# I have methods that use [WebMethod(EnableSession = true)] I consume them in
I have two methods, one that I use to convert an image to a
I have a method that accepts an IEnumerable-decimals and performance various math functions. 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.