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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:11:59+00:00 2026-06-01T23:11:59+00:00

Antescript: I’m aware that there’s a prior SO question whose title sounds like it

  • 0

Antescript: I’m aware that there’s a prior SO question whose title sounds like it refers to the exact same question. It doesn’t.

Anyway, this question is a little weird – there are plenty of better ways to work around the issues here, but I’m curious as to how I could solve my particular dilemma.

Let’s say I have a method that uses varargs to accept an arbitrary number of elements, perhaps of type Integer. If I have an arbitrary-length array of Integers, is there a way for me to call my method with a comma-separated param list composed of each element of said array?

Here’s a brief, contrived example:

Integer[] paramList = new Integer {1, 2, 3};
varMethod(paramList[0], paramList[1], paramList[2]);
// varMethod({{for (param : paramList) {param;}}});

public void varMethod(Integer...values) {
    for (Integer value : values) {
        foo(value);
    }
}

That commented-out line hints at what I want to do. Since the paramList integer is arbitrary length, calling varMethod with each element explicitly requested (line 2) won’t work. What I’m wondering is if there’s a way to dynamically generate the comma-separated param list from the elements of an array.

Again, I realize that in an example like this, there are better ways to approach the entire problem, but please be aware that I’ve simplified the code so that it’s only relevant to the particular issue we’re discussing here. Any workarounds that address my posted code won’t generalize to the problem I’m really working on that led me to formulate this question in the first place.

  • 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-01T23:12:01+00:00Added an answer on June 1, 2026 at 11:12 pm

    I think you’re just looking for:

    varMethod(paramList);
    

    Perhaps you didn’t realize that Integer... is a special variant of a normal Integer[] array. Thus since paramList is already an Integer[] array, you can just pass it directly into the method.

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

Sidebar

Related Questions

I have a binary tree that I need to search through. I'm not searching
I'm trying to write a game and implement scripting so that later on in
First of all, there are other topics covering this subject but they were posted
There is a variety of Game Engines out on the market, free as commercial.
I am having trouble following the AngelScript manual on the proper way to register
Is it possible to invoke a antscript in postdst and presrc call in MQFTE??
I need to replace a particular character in a text file with another character.
I know how I can bind C++ functions to AngelScript, but in my C++
Hi my code is as follow. I use 2 seperate xml files to populate
I am attempting to register the following function from Irrlicht, dimension2df: template <class U>

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.