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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:27:44+00:00 2026-06-14T15:27:44+00:00

I have a generic class which extends another generic class. The abstract class has

  • 0

I have a generic class which extends another generic class.

The abstract class has 2 type parameters, but I need only one in my functions.

Is it save to just assign it a random like String type, or are there any drawbacks to this?

public abstract class AbstractFoo<T, B>
{
   public abstract void read(T item);
}

public class LittleFoo extends AbstractFoo<byte[], String>
{
   @Override
   public void read(byte[] item)
   {
      // work here
   }
}
  • 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-14T15:27:45+00:00Added an answer on June 14, 2026 at 3:27 pm

    No there really isn’t any drawback to this, and it seems like a simple way to do it in my opinion.

    Also, you might want to consider using composition instead of extension. For example, take a look at the HashSet implementation from java.util:

    87   public class HashSet<E>
    88       extends AbstractSet<E>
    89       implements Set<E>, Cloneable, java.io.Serializable
    90   {
    91       static final long serialVersionUID = -5024744406713321676L;
    92   
    93       private transient HashMap<E,Object> map;
    94   
    95       // Dummy value to associate with an Object in the backing Map
    96       private static final Object PRESENT = new Object();
    

    A HashSet is basically a HashMap, but only considers the set of keys (hence the dummy variable PRESENT, which is just a placeholder). You could perhaps do something similar.

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

Sidebar

Related Questions

I'm using my own generic abstract class (MyAsyncTask) which extends AsyncTasks, and need a
I have a parameterized generic class X which takes a type T. On which
I have a class reflecting my dbml file which extends DataContext, but for some
I have a Interface Foo which has a generic type - public interface Foo<T>
I have outer generic class which has some inner class, for which I'd like
I have a problem, I need to resolve type of class which replaced the
I have a generic interface IConstrained which is implemented by the generic Constrained class.
I have a class which provides generic access to LINQ to SQL entities, for
I have a generic class that takes a type T . Within this class
I have a generic base class: public class BaseLabel<T> extends JXLabel { private static

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.