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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:41:09+00:00 2026-05-28T02:41:09+00:00

So, yes I’ve seen this question . However, what if I had two interfaces,

  • 0

So, yes I’ve seen this question. However, what if I had two interfaces, IA and IB, but I wanted a parameter to a function (or property of a class) to be:

public void (<? extends IA, IB> someClass) {
//...
}

Is there a way to do this without using generics?

EDIT:

I’ve realized that what I really want is Duck Typing, like in Python. I just didn’t get my words out right. With that in mind, clearly there is no real way to do this in Java. I accepted this answer, but then realized that the input would have to have the signature of that new interface to work. However, he did meet my awkwardly-worded criteria :).

  • 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-28T02:41:09+00:00Added an answer on May 28, 2026 at 2:41 am
    interface IAandIB extends IA, IB { }
    
    public void Foo(IAandIB someClass) {
    //...
    }
    

    Since interfaces can extend multiple other interfaces, you can just make an empty ‘dummy interface’ that extends both of them, and use it as the type to designate whenever both are required.

    This works, but is not a catch-all solution as it requires you to modify every single class that implements IA and IB so they can work for this method, which is annoying at best and impossible in some situations. Unfortunately, I do not know of any other way to do this without generics.

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

Sidebar

Related Questions

yes, this is a homework-type question but could you please help me out? In
yes i know how silly and dumb this question is, but i have been
Yes, I'm aware that this question has already been post, but ... I'm looking
Yes, this sounds like a simple question, and it probably is. But when i
Yes, this might sound like a newbie question but there's a TWIST! ( And
...Yes I've seen: Best Resources for Learning JavaFX? but it doesn't really answer the
Yes, there is a similar question here . However, that question doesn't seem to
Yes, yes, I've weighed using an xml parser instead of regular expressions, but this
Yes, this is just a question i would like to get an answer on.
Yes, this is rather subjective, but I am doing research on that matter and

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.