facebook

doesn’t create superclass

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #268523 Reply

    douglasv
    Member

    In the “New Java Class” dialog

    in the section “Which stub would you like to create” I always check “Constructors for Super Class’

    and myeclipse Always “NEVER” creates the “Super Class Constructor” , why then the need for a check box
    for something that doesn’t Work????

    #268536 Reply

    Riyad Kalla
    Member

    Please give me details to try and reproduce on my end. For example, which class are you marking as the super class? I will see if I can figure out what is going on.

    #268542 Reply

    douglasv
    Member

    @support-rkalla wrote:

    Please give me details to try and reproduce on my end. For example, which class are you marking as the super class? I will see if I can figure out what is going on.

    this all occurs in the new class dialog, super() .class that will be created from is “java.lang.Object

    #268546 Reply

    Riyad Kalla
    Member

    douglasv,
    I think there may be a misunderstanding, what that feature does is create constructors in your new class that *match* the ones in the super class. The only constructor that Object has is the default no-arg constructor, so there is no constructor to create.

    Try doing the same thing using JButton as the parent class, the wizard will correctly generate all 5 constructors from the parent JButton class, like this:

    
    public TestButton() {
        }
    
        public TestButton(Icon icon) {
            super(icon);
        }
    
        public TestButton(String text) {
            super(text);
        }
    
        public TestButton(Action a) {
            super(a);
        }
    
        public TestButton(String text, Icon icon) {
            super(text, icon);
        }
    
    #268552 Reply

    douglasv
    Member

    @support-rkalla wrote:

    douglasv,
    I think there may be a misunderstanding, what that feature does is create constructors in your new class that *match* the ones in the super class. The only constructor that Object has is the default no-arg constructor, so there is no constructor to create.

    Try doing the same thing using JButton as the parent class, the wizard will correctly generate all 5 constructors from the parent JButton class, like this:

    
    public TestButton() {
        }
    
        public TestButton(Icon icon) {
            super(icon);
        }
    
        public TestButton(String text) {
            super(text);
        }
    
        public TestButton(Action a) {
            super(a);
        }
    
        public TestButton(String text, Icon icon) {
            super(text, icon);
        }
    

    On eclipse I believe you will get :-” super();”- in the default constructor; at least that’s what others get

    #268569 Reply

    Riyad Kalla
    Member

    In that use-case super() is an implicit call, whether you type it or not it will be invoked by the VM. Try it, create a base class that in it’s default constructor prints “Hello!” and then in the subclass print out “World” in it’s default constructor. You will get Hello World.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: doesn’t create superclass

You must be logged in to post in the forum log in