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

R

Razvan

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
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
R

Roedy Green

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.
 
X

xarax

Roedy Green said:
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.
 
T

Tov Are Jacobsen

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,
 
R

Roedy Green

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.
 
T

Tov Are Jacobsen

Den Sat, 17 Jul 2004 18:57:06 +0000, skrev Roedy Green:
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,
 
T

Tov Are Jacobsen

Den Sat, 17 Jul 2004 19:46:26 +0000, skrev Roedy Green:
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,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top