{"id":221,"date":"2010-06-04T00:28:42","date_gmt":"2010-06-03T15:28:42","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2010\/06\/04\/java_static\/"},"modified":"2010-06-04T00:28:42","modified_gmt":"2010-06-03T15:28:42","slug":"java_static","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2010\/06\/04\/java_static\/","title":{"rendered":"Java static \u30af\u30e9\u30b9"},"content":{"rendered":"<p>\u3044\u307e\u306e\u3068\u3053\u308d\u3001\u300c<a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/4822283909?ie=UTF8&amp;tag=typea09-22&amp;linkCode=as2&amp;camp=247&amp;creative=7399&amp;creativeASIN=4822283909\">Google Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u5165\u9580 \u753b\u9762\u4f5c\u6210\u304b\u3089\u30c7\u30d0\u30a4\u30b9\u5236\u5fa1\u307e\u3067\u2015\u2015\u57fa\u672c\u6a5f\u80fd\u306e\u5168\u5bb9<\/a><img loading=\"lazy\" decoding=\"async\" style=\"border-bottom-style: none !important; border-right-style: none !important; margin: 0px; border-top-style: none !important; border-left-style: none !important\" border=\"0\" alt=\"\" src=\"http:\/\/www.assoc-amazon.jp\/e\/ir?t=typea09-22&amp;l=as2&amp;o=9&amp;a=4822283909\" width=\"1\" height=\"1\">\u300d \u3092\u6559\u79d1\u66f8\u3068\u3057\u3066\u30b5\u30f3\u30d7\u30eb\u3092\u5b9f\u88c5\u3057\u305f\u308a\u3057\u3066\u308b\u306e\u3067\u3059\u304c\u3001SQLite \u306e\u30b5\u30f3\u30d7\u30eb\u3067\u3001\u30a4\u30f3\u30ca\u30fc\u30af\u30e9\u30b9\u3092 static \u5ba3\u8a00\u3057\u3066\u308b\u3093\u3067\u3059\u306d\u3002<\/p>\n<p><a href=\"http:\/\/developer.android.com\/resources\/tutorials\/notepad\/index.html\" target=\"_blank\">Google \u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u3082\u540c\u69d8<\/a>\u3067\u3057\u305f\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u3001\u898b\u6163\u308c\u306a\u3044\u8a18\u6cd5\u3060\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u4f7f\u3044\u5206\u3051\u308b\u306e\u3060\u308d\u3046\uff1f<\/p>\n<p>\u3061\u3087\u3063\u3068\u6319\u52d5\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Javastatic_14C18\/static_class.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"static_class\" border=\"0\" alt=\"static_class\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/Javastatic_14C18\/static_class_thumb.jpg\" width=\"206\" height=\"119\"><\/a> <\/p>\n<p>Bar \u30af\u30e9\u30b9\u3068\u3001Foo \u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3002<\/p>\n<p>Bar\u30af\u30e9\u30b9<\/p>\n<pre class=\"prettyprint linenums\">package test;\r\n\r\npublic class Bar {\r\n    private String m_str;\r\n    public Bar() {\r\n        m_str = \"Bar\";\r\n    }\r\n    class Ham {\r\n        public String getValue() {\r\n            \/\/ \u5916\u90e8\u30af\u30e9\u30b9\u306e\u9759\u7684\u3067\u306a\u3044\u30e1\u30f3\u30d0\u30fc\u304c\u53c2\u7167\u3067\u304d\u308b\r\n            return \"Ham | \" + Bar.this.m_str;\r\n        }\r\n    }\r\n    static class Spam {\r\n        public String getValue() {\r\n            \/\/ \u2461 \u5916\u90e8\u30af\u30e9\u30b9\u306e\u9759\u7684\u3067\u306a\u3044\u30e1\u30f3\u30d0\u30fc\u306f\u53c2\u7167\u3067\u304d\u306a\u3044\r\n            \/\/ return Bar.this.m_str;\r\n            return \"Spam\";\r\n        }\r\n    }\r\n    \r\n    public void makeInstance() {\r\n        \/\/ \u2460 \u540c\u3058\u3088\u3046\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306f\u4f5c\u308c\u308b\r\n        System.out.println(new Ham().getValue());\r\n        System.out.println(new Spam().getValue());\r\n    }\r\n}\r\n<\/pre>\n<p>Foo\u30af\u30e9\u30b9<\/p>\n<pre class=\"prettyprint linenums\">package test;\r\n\r\npublic class Foo {\r\n    public static void main(String[] args) {\r\n        \r\n        \/\/ \u2462 \u30af\u30e9\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3067\u304d\u306a\u3044\u3002\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3057\u3066\u304b\u3089\r\n        \/\/ Bar.Ham h = new Bar.Ham();\r\n        Bar.Ham h = new Bar().new Ham();\r\n        \r\n        \/\/ \u2463 \u30af\u30e9\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3067\u304d\u308b\r\n        \/\/ Bar.Spam s = new Bar().new Spam();\r\n        <font color=\"#ff0000\">Bar.Spam s = new Bar.Spam();\r\n<\/font>        \r\n        System.out.println(h.getValue());\r\n        System.out.println(s.getValue());\r\n        \r\n        new Bar().makeInstance();\r\n    }\r\n}\r\n<\/pre>\n<p>\u7d50\u679c<\/p>\n<pre class=\"prettyprint linenums\">Ham | Bar\r\nSpam\r\nHam | Bar\r\nSpam\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>static \u30af\u30e9\u30b9 \u306a\u306e\u3067\u3001\u306a\u3093\u304b\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u4f5c\u308c\u306a\u3044!? \u307f\u305f\u3044\u306b\u601d\u3063\u3066\u3057\u307e\u3046\u304c\u3001\u305d\u3093\u306a\u3053\u3068\u306f\u306a\u3044\u3002<\/p>\n<p>\u305d\u308c\u305e\u308c\u3001<u>\u30a2\u30a6\u30bf\u30fc\u30af\u30e9\u30b9\u304b\u3089\u3001\u30a4\u30f3\u30ca\u30fc\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306f\u4f5c\u6210\u3067\u304d\u308b\u3002(\u2460)<\/u><\/p>\n<p>\u305f\u3060\u3057\u3001\u5f53\u305f\u308a\u524d\u3068\u8a00\u3048\u3070\u5f53\u305f\u308a\u524d\u3060\u304c\u3001<u>sutatic \u30af\u30e9\u30b9\u304b\u3089\u306f\u3001\u30a2\u30a6\u30bf\u30fc\u30af\u30e9\u30b9\u306e static \u3067\u306a\u3044\u30e1\u30f3\u30d0\u30fc\u5909\u6570\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044(\u2461)<\/u><\/p>\n<p>Bar \u306e\u30a4\u30f3\u30ca\u30fc\u30af\u30e9\u30b9\u306e\u3001Ham \u3068 Spam \u306e\u30b9\u30b3\u30fc\u30d7\u6307\u5b9a\u3092\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u3001\u540c\u4e00\u30d1\u30c3\u30b1\u30fc\u30b8\u304b\u3089\u306f\u53c2\u7167\u3067\u304d\u308b\u3002<\/p>\n<p>\u305d\u308c\u305e\u308c\u3001\u3092\u540c\u4e00\u30d1\u30c3\u30b1\u30fc\u30b8\u306e Foo \u30af\u30e9\u30b9\u304b\u3089\u53c2\u7167\u3057\u3066\u307f\u308b\u3002<\/p>\n<p>static \u3067\u306a\u3044\u30a4\u30f3\u30ca\u30fc\u30af\u30e9\u30b9\u3092\u30a2\u30a6\u30bf\u30fc\u30af\u30e9\u30b9\u4ee5\u5916\u306e\u30af\u30e9\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3059\u308b\u306b\u306f\u3001\u30a2\u30a6\u30bf\u30fc\u30af\u30e9\u30b9\u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002(\u2462)<\/p>\n<p>\u3057\u304b\uff53\u3001static \u306a\u30a4\u30f3\u30ca\u30fc\u30af\u30e9\u30b9\u306f\u3001<u>\u30a2\u30a6\u30bf\u30fc\u30af\u30e9\u30b9\u4ee5\u5916\u306e\u30af\u30e9\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3059\u308b\u306b\u306f\u3001static \u30e1\u30bd\u30c3\u30c9\u3092\u53c2\u7167\u3059\u308b\u306e\u3068\u540c\u3058\u4ed5\u65b9\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u3067\u304d\u308b\u3002(\u2463)<\/u><\/p>\n<p>\u300c<a href=\"http:\/\/homepage2.nifty.com\/mathpara\/programing\/static.htm\" target=\"_blank\">static\u306e\u3064\u3044\u305f\u5185\u90e8\u30af\u30e9\u30b9\u306f\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u3088\u3046\u306b\u4f7f\u3048\u308b<\/a>\u300d \u3068\u306f\u305d\u3046\u3044\u3046(\u2463)\u610f\u5473\u304b\u3002<\/p>\n<p>\u3061\u3087\u3063\u3068\u3057\u305f\u30af\u30e9\u30b9\u7fa4\u3092\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u306f\u306a\u304f\u3066\u3001\u30af\u30e9\u30b9\u306b\u307e\u3068\u3081\u3066\u4f7f\u3046\u306b\u306f\u3001\u6709\u7528\u305d\u3046\u3060\u3002\u3053\u308c\u304c\u4f7f\u3044\u65b9\u306e\u672c\u547d\u304b\u3057\u3089\u3002<\/p>\n<p>static \u3067\u306a\u3044\u5834\u5408\u306e\u66f8\u304d\u65b9\u3001<\/p>\n<pre class=\"prettyprint linenums\">new Bar().new Ham();<\/pre>\n<p>\u3053\u308c\u306f\u3001\u899a\u3048\u306b\u304f\u3044\u3057\u3001\u9055\u548c\u611f\u3042\u308b\u304c\u3001<\/p>\n<pre class=\"prettyprint linenums\">new Bar.Spam();<\/pre>\n<p>\u3053\u3063\u3061\u306e\u66f8\u304d\u65b9\u306a\u3089\u81ea\u7136\u3060\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3044\u307e\u306e\u3068\u3053\u308d\u3001\u300cGoogle Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u5165\u9580 \u753b\u9762\u4f5c\u6210\u304b\u3089\u30c7\u30d0\u30a4\u30b9\u5236\u5fa1\u307e\u3067\u2015\u2015\u57fa\u672c\u6a5f\u80fd\u306e\u5168\u5bb9\u300d \u3092\u6559\u79d1\u66f8\u3068\u3057\u3066\u30b5\u30f3\u30d7\u30eb\u3092\u5b9f\u88c5\u3057\u305f\u308a\u3057\u3066\u308b\u306e\u3067\u3059\u304c\u3001SQLite \u306e\u30b5\u30f3\u30d7\u30eb\u3067\u3001\u30a4\u30f3\u30ca\u30fc\u30af\u30e9\u30b9\u3092 st [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[39,6],"tags":[],"class_list":["post-221","post","type-post","status-publish","format-standard","hentry","category-android","category-java"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=221"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/221\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}