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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:27:24+00:00 2026-05-30T20:27:24+00:00

I have two formats of a class BaseButton : public abstract class BaseButton<E extends

  • 0

I have two formats of a class BaseButton:

public abstract class BaseButton<E extends BaseButton<E>> extends JXButton implements Initializer {

    private static final long serialVersionUID = 11L;

    public BaseButton() {
        LibraryLogger.initMessage(ClassUtils.getInstance().getResolvedClassName(this.getClass()));  
        initialize();
    }

    public abstract void initialize();
}

And:

public abstract class BaseButton<E> extends JXButton implements Initializer {

    private static final long serialVersionUID = 11L;

    public BaseButton() {
        LibraryLogger.initMessage(ClassUtils.getInstance().getResolvedClassName(this.getClass()));  
        initialize();
    }

    public abstract void initialize();
}

And I am creating child classes as:

public class GreenButton extends BaseButton<GreenButton> {

}

My question is what is the difference between these two types of generic notation?

Which one is better and why?

Any information will be very helpful to me.

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-30T20:27:26+00:00Added an answer on May 30, 2026 at 8:27 pm

    With the code you provided, it makes no difference.

    However, when you start using the generic type E, that’s when you’ll start seeing a difference.
    In the first example, E will have all the methods and members of BaseButton. So, if BaseButton has a method int foo(String s), you will be able to say:

    int bar(E arg) {
        arg.foo("test");
    }
    

    If you try the same thing with the second example, the compiler will report an error, because E implicitly extends Object and Object does not have a foo method.

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

Sidebar

Related Questions

I have the option of writing two different formats for a database structure: Article
I have two classes: class User < ActiveRecord::Base :has_one :foo end class Foo <
I have two methods in the same class and would like to find out
I have two models for Publications and Employees: class Publication(models.Model): BOOK_CHAPTER = 1 ARTICLE
I have two models: Product and ProductType: Product: class Product < ActiveRecord::Base default_scope :order
I have two threads running from a controller class. The first thread receives SMS
I have two model as follows class User < ActiveRecord::Base validates_associated :account end class
I have two models with a one-to-one association. class User < ActiveRecord::Base has_one :setting
I have two class as trial.java and ImageWoLab0.java(Image without lable 0).When I run my
I have two class Group and Permission ,Group has a list of Permission when

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.