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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:11:34+00:00 2026-06-12T03:11:34+00:00

In my program, I have a method which is below; private void foo(String title,

  • 0

In my program, I have a method which is below;

private void foo(String title, String[] subtitles, int ... subtitleValues)

My requirement is ;

  • number of subtitles and subtitleValues must be equal. User can send any number of subtitles and subtitle values but as I said equal number of subtitles and subtitleValues.

I don’t want to take both arguments and check their counts in foo function and say your table can not be created because of unequal subtitles and subtitleValues. What I want is; prevent user to send unequal arguments. How can I do that?

Thanks in advance

PS : I didn’t find a proper title, so if you have, please feel free to change it.

  • 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-12T03:11:35+00:00Added an answer on June 12, 2026 at 3:11 am

    You can’t do it like this. What you can do to make your method harder to call wrongly is to use a fluent API for a builder like this:

    class FooBuilder {
      public static FooBuilder withTitle(String title);
      public FooBuilder withSubtitle(String subtitle, int subtitleValue);
      public Foo build();
    }
    

    I left out the implementation for brevity. Then you can call it like this:

    Foo foo = FooBuilder.withTitle("MyTitle").withSubtitle("st1", 1).withSubtitle("st2", 2).build();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method in my C# WinForms program, which checks if X column
I have written sample program which uses XSLT to generate HTML response. Check below
I have a program which gets commands as a string. Each character in the
I'm writing a program in Java and I have a method with a header
I have a program that makes use of the following method to get a
I am looking for a method to monitor a running program that I have
I have these 3 file in my program: sample1.h (method in sample1.cpp are defined
I'm currently writing a program which interacts with I/O devices and needed a method
Here's the thing... I have 2 GUI programs. A Menu Program,which is basically a
Below is the code in which in the run method , I am always

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.