Home > Back-end >  The abstract and a laparoscope, usually connected to a static can modify method
The abstract and a laparoscope, usually connected to a static can modify method

Time:03-09

Abstract: used to declare an abstract method, abstract method has no method body, cannot be called directly, must be used in subclasses overriding to
Static: used to declare a static method, static methods that can be invoked, class and object
Declared with the static method show that this method is not generated when the instance of the class can be directly call, and the abstract methods can be invoked, the contradiction, therefore, the abstract and static cannot even used to modify method


2, the abstract and native

What
Native: used to declare a local method, the realization of the method is implemented by the Java language, such as C, commonly used in Java and the external environment interaction, or interact with the operating system,
Reference: Native methods in Java Native Method

How
A laparoscope, usually connected to a native can with all other Java identifier, except the abstract,

According to
Because native suggest that these methods are implemented, but these are Java implementation body, but the abstract clearly indicate these methods with no implementation body,


3, the abstract and synchronized

What
Synchronized: used to prevent multiple threads to invoke the method of an object at the same time, and can prevent multiple threads at the same time call a laparoscope, usually connected to a static class of the method,

How
The abstract and synchronized can't use at the same time

According to
Can be seen from the synchronized function also, use synchronized is the premise of the method can be called directly, obviously can't and the abstract,

Reference links: https://www.cnblogs.com/upcwanghaibo/p/6527443.html

CodePudding user response:

Good cow force

CodePudding user response:

reference 1st floor KeepSayingNo response:
good cow force
big insight bai said
  • Related