Non access modifiers in Java: Complete Guide

Non access modifiers in Java are used with classes, methods, variables, constructors etc to provide information about their behavior to JVM.

Non access modifiers in Java

Commonly Used Non access modifiers in Java

Non access modifiers in Java are mentioned below.

  • staticThe 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.
  • abstractIf 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.
  • synchronizedControls thread access to a block/method. Please visit All About Synchronization for more in-depth knowledge.
  • transientThe member is skipped when serializing an object. Please visit Serialization in Java for more in-depth knowledge.
  • volatileThe 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.
  • strictfpThis 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.

Leave a Reply

Your email address will not be published. Required fields are marked *