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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:43:52+00:00 2026-06-01T07:43:52+00:00

A while back I was playing with methods using variable-length argument lists (java) that

  • 0

A while back I was playing with methods using variable-length argument lists (java) that get defined as below

public static int[] makeArray (int... a) {
return a;
}

this is a silly program but what it will do is take in an undefined amount of integers and create an array out of them so all of the below would call on the same method

makeArray(1);
makeArray(1,2);
makeArray(1,2,3);

now what I am looking to do is create a method that will have the same effect but using arrays instead of integers. I was thinking it could maybe do this by putting the arrays into a 2d array but I am not 100% sure if this is possible as the arrays could that get added could vary in size. (maybe even for this reason it isn’t possible?). But as far as I know 2d array is the only way to make an array of arrays.

I have tried (please note this isn’t the actual use I have for this, I just used this to experiment to see how to do this)

public static int countArrays(int[]... a) {
return a.length;
}

and this didn’t compile.

Can anyone make any suggestions?

for anyone that is interested. What I want to do is create a method that will take in X many arrays and then based on that run for loops such that it adds all the array

eg:

int[] sum = new int[a[0].length];
for (int i=0; i<a.length; i++){
for (int j=0; j<a[0].length; j++){
n[i] += a[i][j];
}}
  • 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-01T07:43:53+00:00Added an answer on June 1, 2026 at 7:43 am

    Not sure why you say it doesn’t compile – the following example works for me (compiles and prints 2):

    public static void main(String[] args) throws Exception {
        int[] i1 = new int[]{1,2,3};
        int[] i2 = new int[]{1,2,3};
        int count = countArrays(i1, i2);
        System.out.println(count);
    }
    
    public static int countArrays(int[]... a) {
        return a.length;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A while back I created a lightbox plugin using jQuery that would load a
A while back I was reading the W3C article on ' Re-using Strings in
A while back a found a great-looking framework that allowed .net developers to implement
a while back, CNET had these really cool Social Share buttons, that when you
When I open a view with presentModalViewController, a back button that I created while
I want to display an animated arrow that goes back and forth (using flex
I am developing a game.if the user presses device back button while playing the
I have an issue when playing video while using the c willRotateToInterfaceOrientation function. Initially,
a while back I ran across a situation where we needed to display message-boxes
A while back I was trying to bruteforce a remote control which sent a

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.