{"id":2971,"date":"2015-06-28T16:54:57","date_gmt":"2015-06-28T08:54:57","guid":{"rendered":"http:\/\/leybreeze.com\/blog\/?p=2971"},"modified":"2015-06-28T16:56:35","modified_gmt":"2015-06-28T08:56:35","slug":"java-%e9%9d%9e%e8%ae%bf%e9%97%ae%e4%bf%ae%e9%a5%b0%e7%ac%a6%e7%ae%80%e8%bf%b0","status":"publish","type":"post","link":"http:\/\/leybreeze.com\/blog\/?p=2971","title":{"rendered":"Java \u975e\u8bbf\u95ee\u4fee\u9970\u7b26\u7b80\u8ff0"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p><strong>abstract<\/strong><\/p>\n<p>\u7528\u4e8e\u5b9a\u4e49\u62bd\u8c61\u65b9\u6cd5\u3002\u62bd\u8c61\u65b9\u6cd5\u4ec5\u5177\u6709\u7b7e\u540d\uff08\u65b9\u6cd5\u540d\u3001\u53c2\u6570\u4e0e\u8fd4\u56de\u503c\uff09\uff0c\u9700\u8fdb\u4e00\u6b65\u8986\u76d6\u4f7f\u7528\u3002\u5305\u542b\u62bd\u8c61\u65b9\u6cd5\u7684\u7c7b\u79f0\u4e3a\u62bd\u8c61\u7c7b\uff0c\u540c\u6837\u9700\u8981\u6dfb\u52a0 abstract \u4fee\u9970\u7b26\u3002\u7ee7\u627f\u62bd\u8c61\u7c7b\u65f6\u5fc5\u987b\u8986\u76d6\u5176\u4e2d\u6240\u6709\u7684\u62bd\u8c61\u65b9\u6cd5\u3002interface \u6307\u4ee4\u4e5f\u8d77\u5230\u4e86\u62bd\u8c61\u7684\u529f\u80fd\uff0c\u56e0\u6b64\u5e38\u7701\u7565\u91cd\u590d\u4f7f\u7528 abstract\u3002<\/p>\n<pre lang=\"JAVA\">abstract class AnAbstractClass{\r\n  abstract void anAbstractMethod();\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>static<\/strong><\/p>\n<p>\u7528\u4e8e\u5b9a\u4e49\u9759\u6001\u6210\u5458\uff08\u5b57\u6bb5\u6216\u65b9\u6cd5\uff09\u3002\u9759\u6001\u6210\u5458\u65e0\u9700\u5b9e\u4f8b\u5316\u5373\u53ef\u8bbf\u95ee\u3002<\/p>\n<pre lang=\"JAVA\">public class AStaticClass{\r\n \r\n  static String aStaticField= \"This is a static field.\";\r\n  static void aStaticMethod() {\r\n    System.out.println(\"This is a static method.\");\r\n  }\r\n   \r\n  public static void main(String[] args) {\r\n    System.out.println(AStaticClass.aStaticField);  \r\n    AStaticClass.aStaticMethod();  \r\n  }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>final<\/strong><\/p>\n<p>final \u65b9\u6cd5\u65e0\u6cd5\u8986\u76d6\u3001final \u5b57\u6bb5\u65e0\u6cd5\u518d\u6b21\u8d4b\u503c\u3001final \u7c7b\u65e0\u6cd5\u88ab\u7ee7\u627f\u3002<\/p>\n<pre lang=\"JAVA\">final class AFinalClass {\r\n  final int aFinalField = 0;\r\n  final void aFinalMethod() {\r\n  }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>transient<\/strong><\/p>\n<p>transient \u5bf9\u8c61\u4e0d\u4f1a\u88ab\u5e8f\u5217\u5316\u3002\u6709\u65f6\uff0c\u4e3a\u4e86\u5c06\u5bf9\u8c61\u901a\u8fc7\u7f51\u7edc\u4f20\u8f93\u6216\u5b58\u5165\u6570\u636e\u5e93\uff0c\u9700\u8981\u5c06\u5e8f\u5217\u5316\uff08\u5982\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u5f62\u5f0f\uff09\u3002\u5bf9\u4e8e\u4e00\u4e9b\u4e34\u65f6\u53d8\u91cf\uff0c\u6216\u5176\u4ed6\u4e00\u4e9b\u7279\u6b8a\u539f\u56e0\uff0c\u53ef\u901a\u8fc7 transient \u4fee\u9970\u7b26\u662f\u6210\u5458\u514d\u4e8e\u5e8f\u5217\u5316\u3002<\/p>\n<pre lang=\"JAVA\">class MyClass implements Serializable {\r\n  private String aSerializableString;\r\n  private transient String aTemporaryString; \/\/ \u8be5\u5b57\u7b26\u4e32\u4e0d\u4f1a\u88ab\u5e8f\u5217\u5316\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>volatile<\/strong><\/p>\n<p>\u591a\u7ebf\u7a0b\u5904\u7406\u4e2d\uff0c\u5404\u7ebf\u7a0b\u7684\u6210\u5458\u5c06\u5404\u81ea\u5206\u914d\u7f13\u5b58\u3002volatile \u4fee\u9970\u7b26\u5f3a\u5236\u6240\u6709\u7ebf\u7a0b\u4e2d\u7684\u6210\u5458\u5171\u7528\u540c\u4e00\u7f13\u5b58\uff0c\u5171\u4eab\u76f8\u540c\u7684\u503c\u3002<\/p>\n<pre lang=\"JAVA\">class MyClass {\r\n  volatile int shareValue;\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>synchronized<\/strong><\/p>\n<p>synchronized \u4fee\u9970\u7b26\u4f7f\u6210\u5458\u65e0\u6cd5\u88ab\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bbf\u95ee\uff0c\u5fc5\u987b\u4f9d\u6b21\u8fdb\u884c\uff08\u540c\u6b65\u5904\u7406\uff09\u3002\u5982\u679c\u65b9\u6cd5\u5206\u5c5e\u4e0d\u540c\u5b9e\u4f8b\uff0csynchronized \u5c06\u65e0\u6cd5\u786e\u4fdd\u5904\u7406\u540c\u6b65\u3002<\/p>\n<pre lang=\"JAVA\">class MyClass {\r\n  synchronized void synchronizedProcess() { }\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>native<\/strong><\/p>\n<p>native \u4fee\u9970\u7b26\u8868\u793a\u65b9\u6cd5\u7531\u975e Java \u8bed\u8a00\u5b9e\u73b0\uff0c\u56e0\u6b64\uff0c\u65b9\u6cd5\u4f53\u5c06\u88ab\u7701\u7565\u3002\u968f\u7740 Java \u6027\u80fd\u7684\u6539\u5584\uff0cnative \u7684\u5e94\u7528\u8303\u56f4\u4e5f\u9010\u6e10\u7f29\u5c0f\u3002<\/p>\n<pre lang=\"JAVA\">public native int hashCode(); \r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>strictfp<\/strong><\/p>\n<p>strictfp \u4fee\u9970\u7b26\u8981\u6c42\u7a0b\u5e8f\u4e25\u683c\u9075\u5faa IEEE 754 \u6807\u51c6\u5bf9\u6d6e\u70b9\u5c0f\u6570\u8fdb\u884c\u8ba1\u7b97\u3002\u6b64\u65f6\uff0c\u4e0d\u540c\u73af\u5883\u4e2d\u6d6e\u70b9\u6570\u8fd0\u7b97\u7684\u8bef\u5dee\u4e0d\u590d\u5b58\u5728\uff0c\u4f46\u5904\u7406\u901f\u5ea6\u5c06\u6709\u6240\u4e0b\u964d\u3002<\/p>\n<pre lang=\"JAVA\">strictfp double val;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; abstract \u7528\u4e8e\u5b9a\u4e49\u62bd\u8c61\u65b9\u6cd5\u3002\u62bd\u8c61\u65b9\u6cd5\u4ec5\u5177\u6709\u7b7e\u540d\uff08\u65b9\u6cd5\u540d\u3001\u53c2\u6570\u4e0e\u8fd4\u56de\u503c\uff09\uff0c\u9700\u8fdb\u4e00\u6b65\u8986\u76d6\u4f7f\u7528 &hellip; <a href=\"http:\/\/leybreeze.com\/blog\/?p=2971\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cJava \u975e\u8bbf\u95ee\u4fee\u9970\u7b26\u7b80\u8ff0\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[135],"tags":[123],"_links":{"self":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2971"}],"collection":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2971"}],"version-history":[{"count":4,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2971\/revisions"}],"predecessor-version":[{"id":2976,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2971\/revisions\/2976"}],"wp:attachment":[{"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2971"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/leybreeze.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}