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