What is the difference between access specifiers and access modifiers?

Viewed 67950

In Java, are access specifiers and access modifiers the same thing?

9 Answers

"access modifier" is the official term for private, protected and public used in the Java language specification. "access specifier" is used synonymously in the Java API doc, but this is the first time I've noticed that. It's probably better to stick with the JLS term.

There is nothing known as "Access specifiers" in java, there are only Access modifiers in java

The misconception is from languages like C++ where public, private, protected, default are considered as Access specifiers and remaining (static, final, etc) are considered as access modifiers

Following is the proof as compiler says "modifier private not allowed here" i.e. compiler said modifier and not specifier

enter image description here

According to me, yes, both terms refer to the same thing and are used interchangeably.

That JDI reference is the only place I have ever seen the term 'access specifier' used in a Java specification. Even there, public/protected/private/package are also called 'modifiers'. There's really no reason to ever use the term 'access specifier' in Java, it is clearly just a mistake on one page out of many thousands.

Technically speaking private, public, protected and default are treated as access specifiers. These deal with who can ... questions. The modifiers afaik are volatile, final, static, transient etc. These deal with how does .. aspect.

Related