1

Can anyone tell how many Non-access Modifiers there are in Java? I have the list below, but I want to know if it is complete or if there's any other I need to add:

final,
abstract,
static,
strictfp,
native,
synchronized,
transient
Ray
  • 3,864
  • 7
  • 24
  • 36

3 Answers3

0

It's always best to go to the source: The Java Language Specification. Looking at the keyword section, you can get this list:

  • default
  • transient
  • final
  • static
  • strictfp
  • volatile
  • const
  • native
  • synchronized
Michael Bar-Sinai
  • 2,729
  • 20
  • 27
  • **From that keyword list how do you the list of non-access modifier?** – Revathi Muthukrishnan Mar 30 '15 at 08:28
  • You should look them up in the specs, e.g. 8.3.1 here: http://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.3. I didn't see a place in the spec where they explicitly answer this question, though. They don't distinguish between access and non-access modifiers there – Michael Bar-Sinai Mar 30 '15 at 08:41
0

I don't think Michael Bar-Sinai's answer is correct.

The Modifier class shows a total of 12 modifiers, and this page of the Java Documentation shows that there are 3 access modifiers (and a 4th nameless package-private modifier). It follows that the 9 non-access modifiers are:

  1. abstract
  2. final
  3. interface
  4. native
  5. static
  6. strictfp
  7. synchronized
  8. transient
  9. volatile
Ray
  • 3,864
  • 7
  • 24
  • 36
0
  1. abstract
  2. static
  3. final
  4. synchronized
  5. native
  6. strictfp
  7. transient
  8. volatile
Lukasz_Plawny
  • 429
  • 7
  • 17