Modifiers applied to attributes, local variables, member functions, classes and inncer classes !

Discussion in 'Java' started by Razvan, Jul 16, 2004.

  1. Razvan

    Razvan Guest

    Hi !



    I wrote the following table to better understand what modifier can be
    applied to what:



    modifiers | attribute | local variables | member func | class |
    inner class
    _______________________________________________________________________________________________________________
    public | yes | no | yes | yes | yes
    protected | yes | no | yes | no | yes
    private | yes | no | yes | no | yes
    abstract | no | no | yes (1) | yes | yes
    static | yes | no | yes | no | yes
    final | yes | yes | yes (2) | yes (3) | yes (3)
    native | no | no | yes (4) | no | no
    synchronized | no | no | yes | no | no
    volatile | yes (5) | no | no | no | no
    transient | yes | no | no | no | no
    strictfp | no | no | yes | yes | yes


    1 - they cannot have a body (this is different from C++ where a pure
    virtual func can have a body)
    2 - means that the method cannot be overloaded or hidden in a
    superclass; (different from C++ where const means that the member
    function is not going to modify the object itself)
    3 - you can't derive from it;
    4 - implemented in some other language
    5 - can be asynchronously modified (just like in C++)



    If you spot any errors or if you think that it is incomplete don't
    hesitate to correct me.


    Is there something like a const member function in Java ? By const
    member function I understand a member function that is not going to
    modify instances of this class when it is called on such an instance.
    (simply put - the C++ meaning of const for member functions)

    This is a very useful feature in C++. I hope that Java too has some
    equivalent.






    Regards,
    Razvan
    Razvan, Jul 16, 2004
    #1
    1. Advertising

  2. Re: Modifiers applied to attributes, local variables, member functions,classes and inncer classes !

    Razvan wrote:
    > I wrote the following table to better understand what modifier can be
    > applied to what:


    Note than in Java, you generally use the word "method" instead of "function".
    I think your table is correct, except for your explanation of "volatile",
    which is too simplistic:

    http://www-106.ibm.com/developerworks/java/library/j-jtp03304/
    Michael Borgwardt, Jul 16, 2004
    #2
    1. Advertising

  3. Razvan

    Roedy Green Guest

    On 16 Jul 2004 06:30:38 -0700, (Razvan) wrote or
    quoted :

    > Is there something like a const member function in Java ? By const
    >member function I understand a member function that is not going to
    >modify instances of this class when it is called on such an instance.
    >(simply put - the C++ meaning of const for member functions)


    I think dynamic loading precludes that. It would take a lot of
    tracking since a method could call a method of another class, which
    might not even exist yet.
    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 16, 2004
    #3
  4. Razvan

    Roedy Green Guest

    On 16 Jul 2004 06:30:38 -0700, (Razvan) wrote or
    quoted :

    >
    >
    >
    > If you spot any errors or if you think that it is incomplete don't
    >hesitate to correct me.


    I have formatted your table, and translated your C++ terminology to
    Java and will soon be posting it at http://mindprod.com/keyword.html

    The entries I would like someone to double check are:

    class private = no
    class protected = no
    class static = no

    They don't make sense, but sometimes hidden away in the JLS is use for
    such beasts.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 16, 2004
    #4
  5. Razvan

    Roedy Green Guest

    On 16 Jul 2004 06:30:38 -0700, (Razvan) wrote or
    quoted :

    >
    >modifiers | attribute | local variables | member func | class |
    >inner class
    >_______________________________________________________________________________________________________________
    >public | yes | no | yes | yes | yes
    >protected | yes | no | yes | no | yes
    >private | yes | no | yes | no | yes
    >abstract | no | no | yes (1) | yes | yes
    >static | yes | no | yes | no | yes
    >final | yes | yes | yes (2) | yes (3) | yes (3)
    >native | no | no | yes (4) | no | no
    >synchronized | no | no | yes | no | no
    >volatile | yes (5) | no | no | no | no
    >transient | yes | no | no | no | no
    >strictfp | no | no | yes | yes | yes
    >


    compare this with the HTML version at
    http://mindprod.com/jgloss/keyword.html

    people are shooting themselves in the foot with their reluctance to
    allow HTML in newsgroup postings.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 16, 2004
    #5
  6. Razvan

    xarax Guest

    "Roedy Green" <> wrote in message
    news:...
    > On 16 Jul 2004 06:30:38 -0700, (Razvan) wrote or
    > quoted :
    >
    > >
    > >
    > >
    > > If you spot any errors or if you think that it is incomplete don't
    > >hesitate to correct me.

    >
    > I have formatted your table, and translated your C++ terminology to
    > Java and will soon be posting it at http://mindprod.com/keyword.html
    >
    > The entries I would like someone to double check are:
    >
    > class private = no
    > class protected = no
    > class static = no
    >
    > They don't make sense, but sometimes hidden away in the JLS is use for
    > such beasts.


    Those only work for nested classes, rather than
    top-level classes.
    xarax, Jul 16, 2004
    #6
  7. Den Fri, 16 Jul 2004 20:01:20 +0000, skrev Roedy Green:
    [...]
    > people are shooting themselves in the foot with their reluctance to
    > allow HTML in newsgroup postings.


    The table looks just fine in a monospaced font.

    cheers,
    Tov Are Jacobsen, Jul 17, 2004
    #7
  8. Razvan

    Roedy Green Guest

    On Sat, 17 Jul 2004 20:06:26 +0200, Tov Are Jacobsen <>
    wrote or quoted :

    >The table looks just fine in a monospaced font.


    not on my machine. You have wrap problems, the table takes up far
    more horizontal space than necessary. You have to manually flip to
    monospaced font to view that message.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 17, 2004
    #8
  9. Den Sat, 17 Jul 2004 18:57:06 +0000, skrev Roedy Green:

    > On Sat, 17 Jul 2004 20:06:26 +0200, Tov Are Jacobsen <>
    > wrote or quoted :
    >
    >>The table looks just fine in a monospaced font.

    >
    > not on my machine. You have wrap problems, the table takes up far
    > more horizontal space than necessary. You have to manually flip to
    > monospaced font to view that message.


    You're right, the table is 109 chars wide, which is way larger than the 76
    character wrap which is good to have, but I don't think HTML is the answer.

    cheers,

    --
    Tov Are Jacobsen
    Tov Are Jacobsen, Jul 17, 2004
    #9
  10. Razvan

    Roedy Green Guest

    On Sat, 17 Jul 2004 21:28:57 +0200, Tov Are Jacobsen <>
    wrote or quoted :

    >
    >You're right, the table is 109 chars wide, which is way larger than the 76
    >character wrap which is good to have, but I don't think HTML is the answer.


    look at the table in HTML. See
    http://mindprod.com/jgloss/keyword.html

    You gotta be kidding if you claim the ASCII is more readable.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jul 17, 2004
    #10
  11. Den Sat, 17 Jul 2004 19:46:26 +0000, skrev Roedy Green:

    > On Sat, 17 Jul 2004 21:28:57 +0200, Tov Are Jacobsen <>
    > wrote or quoted :
    >
    >>
    >>You're right, the table is 109 chars wide, which is way larger than the 76
    >>character wrap which is good to have, but I don't think HTML is the answer.

    >
    > look at the table in HTML. See
    > http://mindprod.com/jgloss/keyword.html
    >
    > You gotta be kidding if you claim the ASCII is more readable.


    Yes, your table is very readable.....and it's available through a
    different communication protocol with a different client.

    Your table would have looked even nicer in pdf, or maybe in a nice
    3D animated divx movie ... hardly the point however; ASCII works.

    cheers,

    --
    Tov Are Jacobsen
    Tov Are Jacobsen, Jul 17, 2004
    #11
  12. On Sat, 17 Jul 2004 21:48:27 +0200, Tov Are Jacobsen wrote:

    > ..hardly the point however; ASCII works.


    I agree.
    Andrew Thompson, Jul 17, 2004
    #12
    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. shila
    Replies:
    3
    Views:
    673
    Tor Iver Wilhelmsen
    Feb 24, 2004
  2. Tony Morris

    Local Classes - Access Modifiers?

    Tony Morris, Jan 14, 2006, in forum: Java
    Replies:
    10
    Views:
    922
    Stefan Schulz
    Jan 16, 2006
  3. Hicham Mouline
    Replies:
    0
    Views:
    425
    Hicham Mouline
    Apr 23, 2009
  4. Hicham Mouline
    Replies:
    1
    Views:
    409
    Michael DOUBEZ
    Apr 24, 2009
  5. Miquel

    Class & modifiers modifiers

    Miquel, Jan 25, 2007, in forum: Ruby
    Replies:
    4
    Views:
    162
    Miquel
    Jan 26, 2007
Loading...

Share This Page