can't call super from method but I need to??

Discussion in 'Java' started by caultonpos@gmail.com, Dec 30, 2007.

  1. Guest

    See below, how can I call animals growl while within a method of my
    interface (I need that - cant get rid of it).

    public class animal {
    public void growl() {
    System.out.println("growl");
    }
    }

    public class dog extends animal {


    public void growl() {
    IDefaultCall default = new IDefaultCall () {

    public void execute() {
    // I can do it this as super. points to IDefaultCell !
    super.growl();
    }
    };
    call (default);
    }

    }
     
    , Dec 30, 2007
    #1
    1. Advertising

  2. Daniel Pitts Guest

    wrote:
    > See below, how can I call animals growl while within a method of my
    > interface (I need that - cant get rid of it).
    >
    > public class animal {
    > public void growl() {
    > System.out.println("growl");
    > }
    > }
    >
    > public class dog extends animal {
    >
    >
    > public void growl() {
    > IDefaultCall default = new IDefaultCall () {
    >
    > public void execute() {
    > // I can do it this as super. points to IDefaultCell !
    > super.growl();
    > }
    > };
    > call (default);
    > }
    >
    > }

    First, class names should be UpperCase.

    I think the syntax you're looking for is something like dog.super.growl();


    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
     
    Daniel Pitts, Dec 30, 2007
    #2
    1. Advertising

  3. Guest

    On Dec 30, 6:32 pm, Daniel Pitts
    <> wrote:
    > wrote:
    > > See below, how can I call animals growl while within a method of my
    > > interface (I need that - cant get rid of it).

    >
    > > public class animal {
    > >    public void growl() {
    > >       System.out.println("growl");
    > >    }
    > > }

    >
    > > public class dog extends animal {

    >
    > >    public void growl() {
    > >       IDefaultCall default = new IDefaultCall () {

    >
    > >         public void execute() {
    > >            // I can do it this as super. points to IDefaultCell !
    > >            super.growl();
    > >         }
    > >        };
    > >       call (default);
    > >    }

    >
    > > }

    >
    > First, class names should be UpperCase.
    >
    > I think the syntax you're looking for is something like dog.super.growl();
    >
    > --
    > Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>- Hide quoted text -
    >
    > - Show quoted text -


    Yes I just typed here in lowercase.

    Even if it looks like a static method call that syntax works, learn
    something every day.
     
    , Dec 31, 2007
    #3
  4. Lew Guest

    Daniel Pitts
    >> First, class names should be UpperCase.


    wrote:
    > Yes I just typed here in lowercase.


    Yes, that would be the reason Daniel drew your attention to it.

    --
    Lew
     
    Lew, Dec 31, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    super.super.super how?

    Guest, Feb 19, 2005, in forum: Java
    Replies:
    24
    Views:
    10,789
    Darryl Pierce
    Feb 24, 2005
  2. Fernando Rodriguez

    Getting the super class via the super() function

    Fernando Rodriguez, Nov 21, 2003, in forum: Python
    Replies:
    2
    Views:
    724
    Bob Willan
    Nov 22, 2003
  3. Kerim Borchaev

    super. could there be a simpler super?

    Kerim Borchaev, Jan 15, 2004, in forum: Python
    Replies:
    4
    Views:
    478
    Michele Simionato
    Jan 15, 2004
  4. Replies:
    7
    Views:
    450
    Patricia Shanahan
    Apr 6, 2008
  5. zweibieren

    A need for super.super.method()

    zweibieren, May 7, 2009, in forum: Java
    Replies:
    0
    Views:
    451
    zweibieren
    May 7, 2009
Loading...

Share This Page