Hi guys,
Following is a summary about the combination of Java keywords.
Hope it will be useful for all Java guys.
For any question, please contact yexianyi@hotmail.com
Thanks,
Xianyi.Ye
Java Keywords Combination Summary
|
private |
protected |
public |
abstract |
static |
final |
synchronized |
native |
General Class Declaration |
Same as the declaration of interface and abstract class |
√ |
√ |
Only Inner class could be declared as static |
√ |
Synchronized and native only could be used for method declaration |
General Class Member Variables |
√ |
√ |
√ |
√ |
√ |
√ |
Synchronized and native only could be used for method declaration |
General Class Member Method |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
Interface Declaration |
Same as General class declaration, interface only could be declared as public and abstract |
√ |
√ |
Since the purpose of declaring interface is to make derived class inherit it, so it is not allowed to set interface as final. |
Interface Member Variables |
|
√ (d) |
|
√ (d) |
√ (d) |
Default type of interface variable is public, static and final. |
Interface Method |
|
√ (d) |
√ (d) |
Default type of interface method is public and abstract. |
Abstract Class Declaration |
Same as General class declaration, abstract class only could be declared as public and abstract |
√ |
√ |
Since the purpose of declaring abstract class is to make derived class inherit it, so it is not allowed to set abstract class as final. |
Abstract Class Member Variables |
√ |
√ |
√ |
|
√ |
√ |
Synchronized and native only could be used for method declaration |
Abstract Class Method |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
Inner Class Declaration |
√ |
√ |
√ |
√ |
√ |
√ |
Synchronized and native only could be used for method declaration |
Inner Class Member Variables |
√ |
√ |
√ |
|
√ (If class is static ) |
√ |
Synchronized and native only could be used for method declaration |
Inner Class Method |
√ |
√ |
√ |
√ |
√ (If class is static ) |
√ |
√ |
√ |
Anonymous Inner Class Member Variables |
√ |
√ |
√ |
Since the declaration and definition of Anonymous Inner Class is bound together, so we cannot set the keyword static on both declaration and Member variables |
√ |
Synchronized and native only could be used for method declaration |
Anonymous Inner Class Method |
√ |
√ |
√ |
Since the declaration and definition of Anonymous Inner Class is bound together, so we cannot declare method as abstract as well as static. |
√ |
√ |
√ |