Home  >  Article  >  Java  >  How many non-access modifiers are there in Java?

How many non-access modifiers are there in Java?

WBOY
WBOYforward
2023-08-30 18:01:08953browse

How many non-access modifiers are there in Java?

Java provides some other modifiers to provide functionality beyond visibility. These modifiers are called non-access modifiers

  • static Members declared as static are common to all instances of the class. Static members are class-level members that are stored in class memory.
  • Final This modifier is used to restrict further modifications to a variable, method, or class. The value of a variable declared final cannot be modified once it obtains its value. Final methods cannot be overridden in subclasses, nor can you create subclasses of the Final class.
  • AbstractThis modifier can be used with a class or method. You cannot apply this modifier to variables and constructors. Methods declared abstract must be modified in subclasses. You cannot instantiate a class declared abstract.
  • SynchronizationThis modifier is used to control access to a specific method or block by multiple threads. Only one thread can enter a method or block declared as synchronized.
  • Transient This modifier is used in the serialization process. Variables declared as transient are not serialized during object serialization.
  • Volatile The volatile modifier is used in multi-threaded programming. If you declare a field as volatile, it signals to threads that its value must be read from main memory rather than from their own stack. Because volatile fields are common to all threads and will be updated frequently by multiple threads.
  • Strictfp This modifier is used for floating point calculations. This keyword ensures that you get the same floating point representation on every platform. This modifier makes floating point variables more consistent across multiple platforms.

The above is the detailed content of How many non-access modifiers are there in Java?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete