Nested Class, Member Class, Inner Class, Local Class, Anonymous Class

Discussion in 'Java' started by E11, Oct 12, 2005.

  1. E11

    E11 Guest

    Hi,

    What is actually the difference between a Nested Class, a Member Class,
    an Inner Class, a Local Class, and an Anonymous Class?

    This is what i know so far:

    A nested class is probably a generic term for all Class declaration
    that are not top-level declarations. i.e. so member classes, inner
    classes, local classes and anonymous classes are all nested classes. Is
    that correct?

    An anonymous class doesn't have a formal class name. e.g. we declare an
    anonymous class that implements an ActionListener as follows:
    ActionListener al = new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
    }
    }

    An inner class, from what i know, is a nested class that is NOT static?

    What then is a local class? And what's a member class?



    Thanks and Regards,
    Edwin
     
    E11, Oct 12, 2005
    #1
    1. Advertising

  2. Re: Nested Class, Member Class, Inner Class, Local Class, AnonymousClass

    E11 wrote:
    > What is actually the difference between a Nested Class, a Member Class,
    > an Inner Class, a Local Class, and an Anonymous Class?


    Please don't cross post questions. Posting to comp.lang.java.help would
    have been enough. F'up set. Also, any good java text book should give
    you a detailed answer (homework?).

    In short:

    * nested (top-level) class:

    A class defined as static inside another class. Instances can live
    independent of instances of the enclosing class. It's a normal class,
    just with a longer name.

    * member (inner) class:

    A class defined as non-static inside another class. Instances are
    dependent on an instance of the enclosing class.

    * inner class:

    A member, local or anonymous class

    * local (inner) class:

    Defined inside a code block, only visible inside that code block

    * anonymous (inner) class:

    A local class without a name.

    /Thomas

    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    Thomas Weidenfeller, Oct 12, 2005
    #2
    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. Gary
    Replies:
    2
    Views:
    5,597
    _nuhb_
    Aug 14, 2003
  2. Bruce Sam
    Replies:
    5
    Views:
    7,838
    Mike Schilling
    Jan 13, 2005
  3. Replies:
    5
    Views:
    713
    John C. Bollinger
    Mar 3, 2005
  4. Pyenos
    Replies:
    2
    Views:
    392
    Pyenos
    Dec 27, 2006
  5. Reporter
    Replies:
    3
    Views:
    482
    Mike Schilling
    May 12, 2007
Loading...

Share This Page