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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:18:38+00:00 2026-06-12T09:18:38+00:00

(Working in Java) I have an abstract class with generic typing throughout the whole

  • 0

(Working in Java)
I have an abstract class with generic typing throughout the whole class:

public abstract class ConnectionProcessor<T>
{
    public void process()
    {
        for (List<T> resultsPage : connection)
        {
            processPage(resultsPage);
        }
    }

    protected abstract void processPage(List<T> resultsPage);
}

I have another class that extends said abstract class, with the following declaration:

public class AlbumProcessor<Album> extends ConnectionProcessor
{
    @Override
    protected void processPage(List resultsPage)
    {
        //Do stuff here specific to Album
    }
}

This declaration works fine, but in processPage I want to do Album-specific things, and I try to avoid casting when I don’t need to use it. I would PREFER this to be the method declaration:

protected void processPage(List<Album> resultsPage)

But this doesn’t meet the requirements for overriding processPage from ConnectionProcessor. Why is this? How can I get the desired behavior? I would think that in AlbumProcessor I could just plug in <Album> everywhere ConnectionProcessor has <T>, but that just isn’t the case.

  • 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-12T09:18:39+00:00Added an answer on June 12, 2026 at 9:18 am

    Try

    //extend prameterized version of ConnectionProcessor<T> with Album as actual type argument
    public class AlbumProcessor extends ConnectionProcessor<Album> {
    

    instead of

    public class AlbumProcessor<Album> extends ConnectionProcessor {
    

    When you do the above you are exteding the raw version of the generic type ConnectionProcessor<T> and introducing a new formal type parameter – Album (like T) which is not an actual type argument in that case.

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

Sidebar

Related Questions

I have a code: Model.java: public abstract class Model <T> { public static <T>
I have the following classes: public abstract class Generic(){ private int Id; ... }
I'm working with java, trying to use the AudioFormat Class. I have the following
I am working on a java application. The is an abstract class Model and
here is working java code class Cup { public String sayColor() { return i
Im working on java, I have created an enum as follows: public enum myEnum
I have a class with context passed in the constructor : public abstract class
I have been working in Java/J2ee projects, in which I follow the Maven structure.
I have created a couple of java working sets for a project in my
I am working on Java. I have a date for example: 20120328. Year is

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.