Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Modifiers applied to attributes, local variables, member functions, classes and inncer classes !

Reply
Thread Tools

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

 
 
Razvan
Guest
Posts: n/a
 
      07-16-2004
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
 
Reply With Quote
 
 
 
 
Michael Borgwardt
Guest
Posts: n/a
 
      07-16-2004
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/developerwork...ry/j-jtp03304/
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      07-16-2004
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.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-16-2004
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.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-16-2004
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.
 
Reply With Quote
 
xarax
Guest
Posts: n/a
 
      07-16-2004
"Roedy Green" <look-> 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.


 
Reply With Quote
 
Tov Are Jacobsen
Guest
Posts: n/a
 
      07-17-2004
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,


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-17-2004
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.
 
Reply With Quote
 
Tov Are Jacobsen
Guest
Posts: n/a
 
      07-17-2004
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

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      07-17-2004
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class & modifiers modifiers Miquel Ruby 4 01-26-2007 12:33 PM
Local Classes - Access Modifiers? Tony Morris Java 10 01-16-2006 02:49 PM
use of access modifiers... how can I do this, this and this question Indudhar Java 4 10-21-2005 08:52 AM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM
How would I use qsort to sort a struct with a char* member and a long member - I want to sort in order of the long member Angus Comber C Programming 7 02-05-2004 06:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57