{"id":5030,"date":"2018-06-23T13:02:44","date_gmt":"2018-06-23T04:02:44","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=5030"},"modified":"2023-05-27T20:28:15","modified_gmt":"2023-05-27T11:28:15","slug":"%e3%80%90java%e3%80%91%e3%82%a4%e3%83%b3%e3%83%9d%e3%83%bc%e3%83%88%e3%81%ae%e4%bb%95%e6%96%b9","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=5030","title":{"rendered":"\u3010Java\u3011\u30d1\u30c3\u30b1\u30fc\u30b8\u306eimport(\u30a4\u30f3\u30dd\u30fc\u30c8)\u306b\u3064\u3044\u3066(static import\u3082)"},"content":{"rendered":"<h2>import\u6587\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408<\/h2>\n<p>import\u6587\u3092\u4f7f\u308f\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u3001\u4ed6\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b<span style=\"color: #ff0000;\"><strong>FQCN(\u5b8c\u5168\u9650\u5b9a\u30af\u30e9\u30b9\u540d)<\/strong><\/span>\u3068\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u8a18\u8ff0\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"lang:default decode:true\">Strig result = \u30d1\u30c3\u30b1\u30fc\u30b8\u540d.\u30af\u30e9\u30b9\u540d.\u30e1\u30bd\u30c3\u30c9\u540d();<\/pre>\n<p>\u3053\u3046\u3044\u3046\u69cb\u6587\u3060\u3068\u3001\u898b\u305f\u76ee\u3082\u306a\u3093\u3060\u304b\u5197\u9577\u306a\u611f\u3058\u304c\u3057\u307e\u3059\u3057\u3001\u305d\u3082\u305d\u3082\u66f8\u304f\u306e\u304c\u3081\u3093\u3069\u304f\u3055\u3044\u3067\u3059\u3088\u306d\u3002<\/p>\n<h2>import\u6587\u306e\u69cb\u6587<\/h2>\n<p>\u6700\u8fd1\u306eEclispe\u3067\u306f\u3001\u307b\u3068\u3093\u3069\u81ea\u52d5\u3067\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3001import\u6587\u81ea\u4f53\u3092\u3042\u307e\u308a\u610f\u8b58\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306a\u69cb\u6587\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">import \u30d1\u30c3\u30b1\u30fc\u30b8\u540d.\u30af\u30e9\u30b9\u540d;<\/pre>\n<p>\u307e\u305f\u3001<span style=\"color: #ff0000;\"><strong>\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u5c5e\u3059\u308b\u30af\u30e9\u30b9\u3092\u5168\u3066import\u3057\u305f\u3044\u5834\u5408<\/strong><\/span>\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">import \u30d1\u30c3\u30b1\u30fc\u30b8\u540d.*;<\/pre>\n<p>import\u3059\u308c\u3070\u4e0b\u8a18\u306e\u3088\u3046\u306b\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3092\u7701\u7565\u3057\u3066\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">Strig result = \u30af\u30e9\u30b9\u540d.\u30e1\u30bd\u30c3\u30c9\u540d();<\/pre>\n<h2>static import\u3068\u306f\uff1f<\/h2>\n<p>Java5\u304b\u3089\u8ffd\u52a0\u3055\u308c\u305f\u5916\u90e8\u30af\u30e9\u30b9\u306e<span style=\"color: #ff0000;\"><strong>static\u30e1\u30f3\u30d0\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u305f\u3081\u306e\u6a5f\u80fd<\/strong><\/span>\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<h3>\u69cb\u6587<\/h3>\n<p>\u901a\u5e38\u306eimport\u6587\u306b<span style=\"color: #ff0000;\"><strong>static<\/strong><\/span>\u3092\u3064\u3051\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">import static \u30d1\u30c3\u30b1\u30fc\u30b8\u540d.\u30af\u30e9\u30b9\u540d;<\/pre>\n<pre class=\"lang:default decode:true\">import static \u30d1\u30c3\u30b1\u30fc\u30b8\u540d.*;<\/pre>\n<p>import\u3059\u308c\u3070\u4e0b\u8a18\u306e\u3088\u3046\u306b<span style=\"color: #ff0000;\"><strong>\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u3060\u3051\u3067\u306a\u304f\u3001\u30af\u30e9\u30b9\u540d\u3082\u7701\u7565<\/strong><\/span>\u3057\u3066\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">Strig result = \u30e1\u30bd\u30c3\u30c9\u540d();<\/pre>\n<p>static\u306a\u30e1\u30f3\u30d0\u306f\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\u306a\u3057\u3067\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u308b\u306e\u3067\u3053\u306e\u3088\u3046\u306a\u547c\u3073\u51fa\u3057\u65b9\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u308f\u3051\u3067\u3059\u306d\u3002<\/p>\n<h3>\u4f8b<\/h3>\n<p>\u300ccom.xxx\u300d\u30d1\u30c3\u30b1\u30fc\u30b8\u306eFile\u30af\u30e9\u30b9\u306eopen\u30e1\u30bd\u30c3\u30c9\u3078\u30a2\u30af\u30bb\u30b9\u304c\u53ef\u80fd\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true\">import static com.xxx.File.open;<\/pre>\n<p>\u300ccom.xxx\u300d\u30d1\u30c3\u30b1\u30fc\u30b8\u306eTest\u30af\u30e9\u30b9\u306e\u5168\u3066\u306e\u30e1\u30bd\u30c3\u30c9\u3084\u5168\u3066\u306estatic\u306a\u5909\u6570\u3078\u30a2\u30af\u30bb\u30b9\u304c\u53ef\u80fd\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true\">import static com.xxx.Test.*;<\/pre>\n<h3>static import\u306e\u6ce8\u610f\u70b9<\/h3>\n<p>\u3042\u304f\u307e\u3067\u3001static import\u3067import\u3057\u3066\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u300cstatic\u306a\u30e1\u30f3\u30d0\uff08\u30e1\u30bd\u30c3\u30c9\u3001\u5909\u6570\uff09\u300d<\/strong><\/span>\u306e\u307f\u3067\u3059\u3002<\/p>\n<p>\u30af\u30e9\u30b9\u5909\u6570\u3084\u3001\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\u306b\u5bfe\u3057\u3066\u306f\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u3054\u6ce8\u610f\u3092\u3002<\/p>\n<p><span style=\"color: #ff0000;\"><strong>static\u30e1\u30f3\u30d0<\/strong><\/span>\u306b\u3064\u3044\u3066\u306e\u89e3\u8aac\u306f\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u3082\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u4e0d\u5b89\u3067\u3042\u308c\u3070\u3054\u89a7\u4e0b\u3055\u3044\u3002\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u4f7f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"UpnPTD1QJu\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=1935\">\u3010Java\u3011\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\uff1a\u9759\u7684(static)\u30e1\u30f3\u30d0(\u30af\u30e9\u30b9\u5909\u6570\u3001static\u30e1\u30bd\u30c3\u30c9)<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=1935&#038;embed=true#?secret=UpnPTD1QJu\" data-secret=\"UpnPTD1QJu\" width=\"500\" height=\"282\" title=\"&#8220;\u3010Java\u3011\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u6307\u5411\uff1a\u9759\u7684(static)\u30e1\u30f3\u30d0(\u30af\u30e9\u30b9\u5909\u6570\u3001static\u30e1\u30bd\u30c3\u30c9)&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"import\u6587\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408 import\u6587\u3092\u4f7f\u308f\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u3001\u4ed6\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306bFQCN(\u5b8c\u5168\u9650\u5b9a\u30af\u30e9\u30b9\u540d)\u3068\u3057\u3066\u30e1\u30bd\u30c3\u30c9\u3092\u8a18\u8ff0\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002 Strig result = [&hellip;]","protected":false},"author":1,"featured_media":4006,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5030"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5030"}],"version-history":[{"count":14,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5030\/revisions"}],"predecessor-version":[{"id":20216,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/5030\/revisions\/20216"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/media\/4006"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5030"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}