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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:20:30+00:00 2026-06-14T07:20:30+00:00

I have a list declared as below into which I intend to add objects.

  • 0

I have a list declared as below into which I intend to add objects.

List<RecursableAction<Recursable, AbstractContext>> actions = new ArrayList<>();

I have an IdGeneratorItemAction that looks like the below:

public class IdGeneratorItemAction implements RecursableAction<Item, IdGeneratorContext> {
    private IdGeneratorContext context;

    @Override
    public void act(Item recursable) {
    }
}

The interface RecursableAction looks like this:

public interface RecursableAction<R extends Recursable, C extends AbstractContext> {
    void act(R recursable);
}

I try to create an instance of IdGeneratorItemAction and add it to the actions list as follows:

RecursableAction<Recursable, AbstractContext> action = new IdGeneratorItemAction();
actions.add(action);

When I attempt to do that, I get the below compilation error:

RecursableAction<Recursable, AbstractContext> action = new IdGeneratorItemAction();
                                                       ^
Type mismatch: cannot convert from IdGeneratorItemAction to RecursableAction<Recursable,AbstractContext>

I tried to change the delcaration of actions to

List<RecursableAction<? extends Recursable, ? extends AbstractContext>> actions = new ArrayList<>();

But when I do that, I am no longer able to iterate on the actions.

for (RecursableAction<? extends Recursable, ? extends AbstractContext> action : actions) {
    action.act(recursable);
    ^
    The method act(capture#1-of ? extends Recursable) in the type RecursableAction<capture#1-of ? extends Recursable,capture#2-of ? extends AbstractContext> is not applicable for the arguments (Recursable)
}

How to solve this problem?

  • 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-14T07:20:31+00:00Added an answer on June 14, 2026 at 7:20 am

    Without knowing the context it’s hard to advise. Clearly you can’t add an IdGeneratorItemAction to a List<RecursableAction<Recursable, AbstractContext>> because IdGeneratorItemAction is a RecursableAction<Item, IdGeneratorContext> and these are not compatible (in the same way as you can’t assign a List<String> to a variable that expects a List<Object>). But likewise you can’t call act(recursable) on a RecursableAction<? extends Recursable, ? extends AbstractContext> because you don’t know what kind of Recursable it expects.

    If you are in a context where you know all the actions are compatible then you’re OK, for example

    public static <R extends Recursable> void doStuff(
          List<? extends RecursableAction<R, ?>> actions, R recursable) {
      for(RecursableAction<R, ?> action : actions) {
        action.act(recursable);
      }
    }
    
    public static void main(String[] args) {
      List<RecursableAction<Item, IdGeneratorContext>> actions = new ArrayList<>();
      actions.add(new IdGeneratorItemAction());
      doStuff(actions, new Item());
    }
    

    but if not then I don’t think you can achieve what you want without a cast somewhere or other.

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

Sidebar

Related Questions

I have a list which is declared below, at the start I default the
I have declared an ArrayList and DefaultListModel DefaultListModel model; List<AddFlight> Flights = new ArrayList<AddFlight>();
In my one Application I have declared one List public List<double[]> pane1 = new
I have declared: queue<int, list<int> > Q After a series of calls: Q.push(37); Q.pop();
I have a map declared as follows: map < string , list < string
I have List I want to sort Desc by Priority, which is int and
I have one listView in my app, which i is use to list the
I'm trying to keep my HTML very simple. I have a set list which
hi friends i have list bellow List<Authors>listAuthor=new List<Authors>(); in that list i have 100
I have a collection of ComboBox declared as below. val cmbAll = for (i

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.