Java, constructors, this.* and super().

Discussion in 'OT Technology' started by Fantik, Mar 12, 2003.

  1. Fantik

    Fantik Guest

    Could somebody explain this to me briefly. I was looking through some old code that I wrote and I can't remember when you use
    Code:
    super();
    this.someVariable = something;
    
    I know it has to do with inheritance, and that it does calls to the parent constructor, but can't remember why you need to "this" a variable.
     
  2. Shnoogs

    Shnoogs Guest

    ^__________________________________^
     
  3. RaginBajin

    RaginBajin Have you punched a donkey today?

    Joined:
    Dec 24, 2001
    Messages:
    8,740
    Likes Received:
    0
    Location:
    NoVA
    I'm not 100% sure but I'll take a stab at it:

    Doesn't "this" just refer to the current object you are in. It is like setting a scope to a variable.

    And "super" calls the superclass that the current class is inheirted from..
     
  4. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
     
    Last edited: Mar 13, 2003
  5. RaginBajin

    RaginBajin Have you punched a donkey today?

    Joined:
    Dec 24, 2001
    Messages:
    8,740
    Likes Received:
    0
    Location:
    NoVA
    WOOT! I was close...
     

Share This Page