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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:45:44+00:00 2026-05-22T21:45:44+00:00

I have just implemented some classes: public abstract class Job<T extends ViewerUnion>{ […] }

  • 0

I have just implemented some classes:

public abstract class Job<T extends ViewerUnion>{
[...]
}

public abstract class ReturnValueJob<T, S extends ViewerUnion> extends Job<S> {
[...]
}

public class MyReturnJob extends ReturnValueJob<Foo, Baa> {
[...]
}

public class JobExecuter {
public static void execute(List<Job> jobList){
for(Job actJob: jobList){
    actJob.startJob();
}
for(Job actJob: jobList){
    actJob.awaitTimeoutOrFinish();
}
}
}

Now I want to execute this code:

List<Job> list = new LinkedList<MyReturnJob>();
JobExecuter.execute(list);

But Java gives me some error while compiling:

Type mismatch: cannot convert from LinkedList to List

I don’t know why because the MyReturnJob is inheriting the Job.
If I change the definition of the list to LinkedList<MyReturnJob> list = new LinkedList<MyReturnJob>();

The same error is thrown on JobExecuter.execute(list);

Thanks for your help.

Best regards,
Till

  • 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-22T21:45:45+00:00Added an answer on May 22, 2026 at 9:45 pm

    What wrong here??

    The problem is not the change from LinkedList to List, but the change in the contained type. Java generics are not covariant, which means you cannot even do:

    LinkedList<Job> = new LinkedList<MyReturnJob>();
    

    Details…

    For more info, read the “Java theory and practice: Generics gotchas” article. Here its relevant part:

    It turns out there’s a good reason it doesn’t work (…): It would break the type safety generics were supposed to provide. Imagine you could assign a List<Integer> to a List<Number>. Then the following code would allow you to put something that wasn’t an Integer into a List<Integer>:

    List<Integer> li = new ArrayList<Integer>();
    List<Number> ln = li; // illegal
    ln.add(new Float(3.1415));
    

    … applied back to context

    The article example code can be translated into the context of this question like this:

    List<MyReturnJob> li = new LinkedList<MyReturnJob>();
    List<Job> ln = li; // illegal
    ln.add(new FooJob());
    

    where FooJob is declared as:

    public abstract FooJob extends Job<ViewerUnion> {
    [...]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at some Java classes that have the following form: public abstract class
I have following classes: public abstract class CustomerBase { public long CustomerNumber { get;
Just a small question about c++/cli. Abstract classes have abstract methods to be implemented
I'm just learning Qt with C++. I have successfully implemented signals and slots to
I have an abstract functor class that overloads operator() and derived objects that implement
I have an abstract class, AbsClass that implements an interface, IClass . IClass has
Recently have implemented lot of pages with different css classes for my web application.
I have a tree-like structure of abstract classes and case classes representing an Abstract
I just finished reading this post: https://developer.yahoo.com/performance/rules.html#flush and have already implemented a flush after
I have just noticed that a multidimensional array in C# does not implement IEnumerable<T>

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.