Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've read around on the internet and I've heard people say

Access specifiers ::

The access specifier determines how accessible the field is to code in other classes. Access ranges from totally accessible to totally inaccessible. You can optionally declare a field with an access specifier keyword: public, private, or protected.

Access Modifiers ::

You can optionally declare a field with a modifier keyword: final or volatile and/or static and/or transient, abstract, etc.

Is there any difference at all? Because most definitions for access modifiers and access specifiers state the same thing.. which seems so ambiguous.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
299 views
Welcome To Ask or Share your Answers For Others

1 Answer

In this context, you can think of access specifiers as protection specifiers -- they specify where a variable can be accessed from. By contrast, access modifiers are completely different; they specify how variables should (or should not) be accessed; e.g. read-only, volatile, etc.

i.e., a variable can be public but read-only, or it can be private and writable -- the access specifiers have nothing to do with the modifiers.

However, I'm a little surprised that the terminology is for C#, since Microsoft actually calls public and private "access modifiers", and it calls volatile and readonly just plain "modifiers".


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...