Non access modifiers in Java are used with classes, methods, variables, constructors etc to provide information about their behavior to JVM.
Commonly Used Non access modifiers in Java
Non access modifiers in Java are mentioned below.
- static – The member belongs to the class, not to objects of that class. Please visit static keyword for more details.
- final – Variable values can’t be changed once assigned, methods can’t be overridden, classes can’t be inherited. Please visit final keyword for more details.
- abstract – If applied to a method – has to be implemented in a subclass, if applied to a class – contains abstract methods. Please visit abstract keyword : classes and methods for more information.
- synchronized – Controls thread access to a block/method. Please visit All About Synchronization for more in-depth knowledge.
- transient – The member is skipped when serializing an object. Please visit Serialization in Java for more in-depth knowledge.
- volatile –The variable value is always read from the main memory, not from a specific thread’s memory. Please visit volatile keyword for more in-depth knowledge.
- native – A method with native keyword indicates that it is implemented in platform-dependent code, typically written in another programming language such as C, C++. Please visit native keyword for more in-depth knowledge.
- strictfp – This modifier is used for floating-point calculations. This keyword ensures that you will get same floating point presentation on every platform. This modifier makes floating point variable more consistent across multiple platforms. Please visit strictfp for more in-depth knowledge.