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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:58:22+00:00 2026-05-27T20:58:22+00:00

public static void method(Set<?>… sets){} Depending on program flow, above method is called with

  • 0
public static void method(Set<?>... sets){}

Depending on program flow, above method is called with two sets, or with three sets, or more. (Not known at compile time).

Is there a way to constructing the argument list “on the fly”?
sets is of type Set< ?>[ ]

Following was not fruitful:

Set<Set<Integer>> varargs = new HashSet<Set<Integer>>();

(method recognizes varargs just as one set -> no solution)

Set<Integer>[] varargs = new HashSet<Integer>[2];

returns

"Cannot create generic array of HashSet<Integer>" 

I would like to construct an array of arguments, while array size and content is filled at runtime.

  • 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-05-27T20:58:22+00:00Added an answer on May 27, 2026 at 8:58 pm
     Set<Integer>[] varargs = new HashSet[2];
     varargs[0] = new HashSet<Integer>() ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the java main() method: public static void main(String[] args) { HashSet set
I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
Here's my extension method for invoke on a control: public static void Invoke<T>(this T
The method signature of a Java main method is: public static void main(String[] args)
Following is my method to append one file onto another file. public static void
Does a method like this exist anywhere in the framework? public static void Swap<T>(ref
I have the following BL method public static void SomeMethod (List<SomeClass> group) { IEnumerable<SomeClass>
class Program { static void Main(string[] args) { Foo.Calc(Foo); } } public abstract class
public class ThreadStateVerifier { public static void main(String[] args) { // TODO Auto-generated method
I have the class: class Program { static void Main(string[] args) { } public

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.