{"id":543,"date":"2006-01-30T07:00:00","date_gmt":"2006-01-29T22:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2006-01-30-7.html"},"modified":"2017-02-16T17:23:40","modified_gmt":"2017-02-16T08:23:40","slug":"2006-01-30-7","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2006-01-30-7.html","title":{"rendered":"C# \u3067 Java \u306e final \u3068\u540c\u7b49\u306e\u5236\u9650\u3092\u304b\u3051\u308b"},"content":{"rendered":"<p>Java \u30d7\u30ed\u30b0\u30e9\u30de\u304c C# \u3092\u5b66\u3076\u969b\u306e\u30e1\u30e2\u3002final \u306b\u3064\u3044\u3066\u306f\u63a2\u3057\u3066\u3082\u898b\u5f53\u305f\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u66f8\u3044\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h3>\u5b9a\u6570\u30fb\u30d5\u30a3\u30fc\u30eb\u30c9\u306efinal<\/h3>\n<p>\u5b9a\u6570\u306b\u5bfe\u3057\u3066\u306f <a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/e6w8fe1b.aspx\" target=\"_blank\">const \u8b58\u5225\u5b50<\/a>, \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u66f8\u304d\u8fbc\u307f\u7981\u6b62\u30d5\u30a3\u30fc\u30eb\u30c9\u306b\u3064\u3044\u3066\u306f <a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/acdd6hb7.aspx\" target=\"_blank\">readonly \u8b58\u5225\u5b50<\/a>\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Foo {\n    private const int NUM_MAX = 65535; \/\/ \u5b9a\u6570\u5024\u3002\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u306e\u9045\u5ef6\u4ee3\u5165\u304c\u4e0d\u53ef\u3002\n    private readonly int _id; \/\/ \u66f8\u304d\u8fbc\u307f\u7981\u6b62\u5024\u3002\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u9045\u5ef6\u4ee3\u5165\u304c\u53ef\u80fd\u3002\n\n&lt;pre&gt;&lt;code&gt;public Foo(int id){\n    _id = id;\n}\n&lt;\/code&gt;&lt;\/pre&gt;\n\n}\n<\/pre>\n<p>\u30e1\u30bd\u30c3\u30c9\u4e2d\u3067\u3001\u9045\u5ef6\u4ee3\u5165\u3092\u3059\u308b\u65b9\u6cd5\u306f\u306a\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npublic doSomething(){\n    readonly int j = 1; \/\/ \u3053\u308c\u306f\u30a8\u30e9\u30fc\u3002readonly \u306f\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u306e\u307f\u53ef\u80fd\u3002\n    const int N;\n    N = 10; \/\/ \u3053\u308c\u3082\u30a8\u30e9\u30fc\u3002const \u306f\u5ba3\u8a00\u3068\u540c\u6642\u306b\u4ee3\u5165\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3002\n}\n<\/pre>\n<p>\u540c\u69d8\u306b\u3001\u5f15\u6570\u306e final (\u5f15\u6570\u306e\u5909\u6570\u3078\u306e\u518d\u4ee3\u5165\u7981\u6b62)\u3092 C# \u3067\u5229\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npublic void doSomeThing2(const int number); \/\/ const \u306f\u5f15\u6570\u306b\u306f\u9069\u7528\u4e0d\u53ef\n<\/pre>\n<h3>\u30af\u30e9\u30b9\u306efinal<\/h3>\n<p>\u30af\u30e9\u30b9\u306b\u5bfe\u3057\u3066\u306f\u3001<a target=\"_blank\" href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/88c54tsw.aspx\">sealed \u8b58\u5225\u5b50<\/a>\u304c\u540c\u7b49\u306e\u52b9\u679c\u3092\u3082\u3061\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsealed class FinalClass{ \/* \u2026 *\/ }\n<\/pre>\n<h3>\u30e1\u30bd\u30c3\u30c9\u306efinal<\/h3>\n<p>Java \u306b\u304a\u3051\u308b\u30e1\u30bd\u30c3\u30c9\u306e\u5ba3\u8a00\u306b\u5bfe\u3057\u3066\u306e final \u306f\u3001C# \u3067\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u5b9f\u88c5\u306e\u305f\u3081\u3001\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30ba\u30e0\u306b\u3064\u3044\u3066\u306f C# \u306e\u307b\u3046\u304c Java \u3088\u308a\u5236\u9650\u7684\u3068\u3044\u3048\u307e\u3059\u3002<\/p>\n<p>final \u3067\u306a\u3044(\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u53ef\u80fd\u306a)\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3059\u308b\u306b\u306f\u3001\u89aa\u3067 <a href=\"http:\/\/www.microsoft.com\/japan\/msdn\/library\/default.asp?url=\/japan\/msdn\/library\/ja\/csref\/html\/vclrfvirtualpg.asp\" target=\"_blank\">virtual \u8b58\u5225\u5b50<\/a>\u3092\u3064\u3051\u3066\u5ba3\u8a00\u3057\u3001\u304b\u3064\u5b50\u3067 <a href=\"http:\/\/www.microsoft.com\/japan\/msdn\/library\/default.asp?url=\/japan\/msdn\/library\/ja\/csref\/html\/vclrfoverridepg.asp\" target=\"_blank\">override \u8b58\u5225\u5b50<\/a>\u3067\u660e\u793a\u3057\u3066\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u307e\u3059\u3002<\/p>\n<p>override \u8b58\u5225\u5b50\u3092\u3064\u3051\u3066\u3044\u308b\u5834\u5408\u3001\u3055\u3089\u306b\u305d\u306e\u5b50\u30af\u30e9\u30b9\u3067\u3082\u518d\u5e30\u7684\u306b\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u304c\u53ef\u80fd\u3067\u3059\u3002\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u53ef\u80fd\u306a\u30e1\u30bd\u30c3\u30c9\u306b\u5bfe\u3057\u3066\u300c\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u305f\u4e0a\u3067\u5b50\u306b\u306f\u7981\u6b62\u3059\u308b\u300d\u3068\u3044\u3046\u52d5\u4f5c\u3092\u5b9f\u88c5\u3059\u308b\u5834\u5408\u306f\u3001\u30af\u30e9\u30b9\u3068\u540c\u69d8\u306b sealed \u8b58\u5225\u5b50\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Parent {\n    public virtual void Greet(){ \/\/ \u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u53ef\u80fd\n        Console.WriteLine(\u201cHello\u201d);\n    }\n    public void StandUp(){ \/\/ \u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u7981\u6b62\u3002\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3057\u3088\u3046\u3068\u3059\u308b\u3068\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\n        \/\/ \u2026\n    }\n}\n\nclass Child : Parent {\n    public override void Greet(){ \/\/ \u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3002\u660e\u793a\u3057\u306a\u3044\u3068\u30b3\u30f3\u30d1\u30a4\u30eb\u30a8\u30e9\u30fc\n        Console.WriteLine(\u201cHi!!\u201d);\n    }\n}\n\nclass GrandChild : Child {\n    public sealed override void Greet(){ \/\/ \u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3002\u305f\u3060\u3057\u3001\u3053\u306e\u30af\u30e9\u30b9\u306e\u5b50\u306b\u306f\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3092\u8a31\u3055\u306a\u3044\u3002\n    }\n}\n\n<\/pre>\n<h3>\u53c2\u8003:<\/h3>\n<ul>\n<li>\n<p><a href=\"http:\/\/www.microsoft.com\/japan\/msdn\/library\/default.asp?url=\/japan\/msdn\/library\/ja\/csref\/html\/vclrfcsharpkeywords_pg.asp\" target=\"_blank\">C# \u306e\u30ad\u30fc\u30ef\u30fc\u30c9<\/a>(MSDN)<\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/www.atmarkit.co.jp\/bbs\/phpBB\/viewtopic.php?mode=viewtopic&amp;topic=27081&amp;forum=12&amp;start=0\" target=\"_blank\">C# \u3067 Java \u306e final \u306e 1\u6a5f\u80fd\u3092\u4f7f\u3044\u305f\u3044<\/a>(@IT Java Solution Forum)<\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/blogs.wankuma.com\/jeanne\/archive\/2005\/11\/23\/19532.aspx\" target=\"_blank\">J# \u306f final \u306e\u5d50<\/a><\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Java \u30d7\u30ed\u30b0\u30e9\u30de\u304c C# \u3092\u5b66\u3076\u969b\u306e\u30e1\u30e2\u3002final \u306b\u3064\u3044\u3066\u306f\u63a2\u3057\u3066\u3082\u898b\u5f53\u305f\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u66f8\u3044\u3066\u304a\u304d\u307e\u3059\u3002 \u5b9a\u6570\u30fb\u30d5\u30a3\u30fc\u30eb\u30c9\u306efinal \u5b9a\u6570\u306b\u5bfe\u3057\u3066\u306f const \u8b58\u5225\u5b50, \u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u66f8\u304d\u8fbc\u307f\u7981\u6b62 &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2006-01-30-7.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">C# \u3067 Java \u306e final \u3068\u540c\u7b49\u306e\u5236\u9650\u3092\u304b\u3051\u308b<\/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":[129],"tags":[76],"class_list":["post-543","post","type-post","status-publish","format-standard","hentry","category-windows-dev","tag-c"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":1,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":1203,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/543\/revisions\/1203"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}