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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:46:35+00:00 2026-05-26T00:46:35+00:00

I can’t seem to figure out why a method call I’m trying to make

  • 0

I can’t seem to figure out why a method call I’m trying to make doesn’t work.

I’ve looked much around SO before asking this, and while there are (many) threads about similar problems, I couldn’t find one that quite fits my problem..

I have the following code:

(in file Processor.java:)

public interface Processor
{
    Runner<? extends Processor> getRunner();
}

(in file Runner.java:)

public interface Runner<P extends Processor>
{
    int runProcessors(Collection<P> processors);
}

(in some other file, in some method:)

Collection<? extends Processor> processorsCollection = ...;
Runner<? extends Processor> runner = ...;
runner.runProcessors(processorsCollection);

IntelliJ marks the last line as an error:

“RunProcessors (java.util.Collection>) in Runner cannot be applied to (java.util.Collection>)”.

I can’t figure out whats wrong with what I did, especially since the error message is not quite clear..

any suggestions?

thanks.

  • 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-26T00:46:35+00:00Added an answer on May 26, 2026 at 12:46 am

    Both your collection and your runner allow for anything that extend processor. But, you can’t guarantee they’re the same.

    Collection might be Collection<Processor1> and Runner be Runner<Processor2>.

    Whatever method you have that in needs to be typed (I forget the exact syntax, but I’m sure you can find it!)

    void <T extends Processor<T>> foo() {
        Collection<T> procColl = ...
        Runner<T> runner = ...
        runner.runProc(procColl);
    }
    

    Edit:

    @newAcct makes an excellent point: you need to genericize (is that a word?) your Processor. I’ve updated my code snippet above as to reflect this important change.

    public interface Processor<P extends Processor>
    {
        Runner<P> getRunner();
    }
    
    public interface Runner<P extends Processor<P>>
    {
        int runProcessors(Collection<P> processors);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help me trying to find out why this doesn't work. The brushes
Can't work out a way to make an array of buttons in android. This
Can't figure out how to do this in a pretty way : I have
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can anyone tell me what i am doing wrong? I am trying to get
Can some one Guide me to work with these things... What is Model popup
can someone show me the regex for this preg_match. I want to make sure
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can somebody point me to a resource that explains how to go about having

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.