Class modifiers, member variable modifiers, method modifiers in Java object-oriented learning--java

Source: Internet
Author: User
Tags modifier modifiers volatile

Class modifier:

Public (access control) --Declares a class as a public class, which can be accessed by any object, and the main class of a program must be a common class.
abstract--> declares a class as an abstract class, without implementing a method that requires a subclass to provide a method implementation.
final--> A class life as final (that is, a non-inheriting class), indicating that he cannot be inherited by another class.
Friendly --The default modifier, only objects in the same package can use such a class.

Member Variable modifiers:

public (Common access control) ---Specifies that the variable is public, and that he can be accessed by any method of the object.
Private (access control) ---Specifies that the variable allows access only to methods of its own class, and that methods in any other class (including subclasses) are inaccessible.
protected (protect access Control) --Specifies that the variable can not be accessed by its own classes and subclasses. This variable can be overridden in a subclass.
Friendly --classes in the same package can be accessed, and classes in other packages cannot be accessed.
final--> The final modifier, specifying that the value of this variable cannot be changed.
Static modifier ---Specifies that the variable is shared by all objects, that is, all instances can use the variable. Variables belong to this class.
transient (over modifier) --Specifies that the variable is a temporary variable that is reserved by the system and temporarily has no special effect.
volatile (volatile modifier)--- specifies that the variable can be controlled and modified by several threads at the same time.

Method Modifiers:

public (common control character) -- Specifies that this method is public and that he can be called by any object
Private -- --Specifies that this method can only have access to methods such as its own class, and that other classes cannot access (including subclasses)
protected (protect access Control) --Specifies that the method can be accessed by its classes and subclasses.
final--> Specifies that the method cannot be overloaded.
static--> Specifies a method that can be activated without instantiation.
The synchronize--> synchronization modifier, which is used in multiple threads to lock the method to which he belongs before running, to prevent access by other threads, and to unlock after the run is complete.
native--> local modifier. The method body that specifies this method is written outside the program in a different language.

Class modifiers, member variable modifiers, method modifiers in Java object-oriented learning--java

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.