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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:10:52+00:00 2026-06-14T11:10:52+00:00

I have two methods like public void login(String userName, String password) { } public

  • 0

I have two methods like

public void login(String userName, String password)
{

}

public void login(String userName, String password, Object loginOption)
{

}

and I hope to get all of them soloved in a certain method:

public boolean getThingsDone(Object...vargs)
{
    //Do The Real Action
    return true;
}

so I have to make different function call:

public void login(String userName, String password)
{
    getThingsDone(userName,password);
}

public void login(String userName, String password, Object loginOption)
{
    getThingsDone(userName,password,loginOption);
}    

Is there any way that I can put different parameter into one List, so I can make the same call

getThingsDone(parameterList);

I have no idea but declare both method into login(String …vargs), but that will confuse other people use this method.

Is there any one ever meet this problem? Any hint would be appreciated.

  • 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-14T11:10:53+00:00Added an answer on June 14, 2026 at 11:10 am

    You can create a Login class with three attributes: – username, password, loginOption.

    public class Login {
        private String username;
        private String password;
        private Object loginOptions;
    
        // Constructors
        // public accessors.
    }
    

    And in your login method pass Login reference as parameter: –

    public void login(Login login) {
    
    }
    

    So, if you want to pass loginOptions, call it like this: –

    login(new Login(username, password, loginOptions));
    

    else, just use a 2-parameterized constructor of Login class: –

    login(new Login(username, password));
    

    And from login method, call other method like this: –

    getThingsDone(login);
    

    Now in that method, check : – if (login.getLoginOptions() != null). If it is null, then do things related to username and password. And if it is not null, then do things related to all of them.

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

Sidebar

Related Questions

I have two methods declared public void MethodA(object o, Action<string> action) { } public
Suppose i have two methods in a class say public void eat(int i,String s)
Assume I have two methods @Secured(ROLE_ADMIN) @RequestMapping(value = /methodA, method = RequestMethod.GET) public void
if I have two methods: public class A { public void doSomething() { synchronized(A.class)
Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>
I have two methods in my Web API controller as follows: public samplecontroller: webapicontroller
I have written two methods that take and return a string. One converts from
I have two methods exactly like each other but just in a line imagine
i have two classes which have some common methods like funcA(), funcB() and some
I have two classes public class PrepaidPackage { private String name; private String serviceClassID;

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.