{"id":5772,"date":"2017-07-03T19:10:19","date_gmt":"2017-07-03T10:10:19","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=5772"},"modified":"2017-07-03T19:10:19","modified_gmt":"2017-07-03T10:10:19","slug":"androidstudio%e3%81%a7kotlin%e3%82%92%e4%bd%bf%e7%94%a82","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/5772","title":{"rendered":"AndroidStudio\u3067Kotlin\u3092\u4f7f\u7528(2)"},"content":{"rendered":"<p>\u4eca\u56de\u306fKotlin\u306b\u304a\u3051\u308b\u3001\u30af\u30e9\u30b9\u306b\u3064\u3044\u3066\u89e6\u308c\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059<\/p>\n<p><!--more--><\/p>\n<h3>\u30af\u30e9\u30b9\u306e\u5ba3\u8a00<\/h3>\n<p>\u30af\u30e9\u30b9\u306f\u3001<span style=\"color: #0000ff\"><strong>class\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u7528<\/strong><\/span>\u3057\u3066\u5ba3\u8a00\u3057\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px\"><code>class Any{\r\n}\r\n<\/code><\/pre>\n<p>\u30af\u30e9\u30b9\u306e\u5ba3\u8a00\u306f\u3001\u30af\u30e9\u30b9\u540d\u3084\u30af\u30e9\u30b9\u30d8\u30c3\u30c0\u3001{ }\u5185\u306e\u30af\u30e9\u30b9\u672c\u4f53\u3067\u69cb\u6210\u3055\u308c\u307e\u3059<br \/>\n \u4e0b\u8a18\u306e\u3088\u3046\u306b\u30af\u30e9\u30b9\u306b\u672c\u4f53\u304c\u306a\u3044\u5834\u5408\u306b\u306f\u3001{ }\u3092\u7701\u7565\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059<\/p>\n<p>Kotlin\u306e\u30af\u30e9\u30b9\u306b\u5b66\u3076\u4e2d\u3067\u3001\u30d7\u30e9\u30a4\u30de\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3084\u30bb\u30ab\u30f3\u30c0\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u7b49\u3001\u805e\u3044\u305f\u3053\u3068\u304c\u306a\u3044\u3088\u3046\u306a\u7528\u8a9e\u304c\u3067\u3066\u304d\u307e\u3057\u305f<br \/>\n \u30d7\u30e9\u30a4\u30de\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3068\u8a00\u3046\u306e\u306f\u3001\u30af\u30e9\u30b9\u30d8\u30c3\u30c0\u306e\u4e00\u90e8\u3067\u3042\u308a\u3001\u30af\u30e9\u30b9\u540d\u306b\u7d9a\u3044\u3066\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px\"><code>class Any (name:String){\r\n}\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u307e\u305f\u3001<span style=\"color: #0000ff\"><strong>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u3084\u30a2\u30af\u30bb\u30b9\u6307\u5b9a\u3092\u3059\u308b\u5834\u5408\u306b\u306f\u3001constructor\u3092\u4ed8\u3051\u306a\u3051\u308c\u3070\u30a8\u30e9\u30fc<\/strong><\/span>\u3068\u306a\u308a\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px\"><code>class Any public constructor(name:String){\r\n}\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><strong><span style=\"color: #0000ff\">\u30d7\u30e9\u30a4\u30de\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u4e2d\u306b\u306f\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u306a\u3044<\/span><\/strong>\u306e\u3067\u3001init\u5185\u306b\u3066\u30af\u30e9\u30b9\u306e\u521d\u671f\u5316\u306a\u3069\u3092\u884c\u3044\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px\"><code>class Any (name:String){\r\n    init {\r\n        Log.d(\"init\", \"${name}\u3067\u521d\u671f\u5316\u3057\u307e\u3057\u305f\")\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u30bb\u30ab\u30f3\u30c0\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306f\u3001\u30af\u30e9\u30b9\u5185\u3067<strong><span style=\"color: #0000ff\">constructor\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u3063\u3066<\/span><\/strong>\u3001\u8907\u6570\u5ba3\u8a00\u3067\u304d\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px\"><code>class Any (name:String){\r\n    val any_name = name\r\n    init {\r\n        println(\"${name}\u3067\u521d\u671f\u5316\u3057\u307e\u3057\u305f\")\r\n    }\r\n    constructor(age:Int, name:String):this(name){\r\n        Log.d(\"constructor\", name)\r\n    }\r\n}\r\n<\/code><\/pre>\n<h3>\u30af\u30e9\u30b9\u306e\u5229\u7528<\/h3>\n<p>\u5148\u7a0b\u5ba3\u8a00\u3057\u305f\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u751f\u6210\u3092\u3059\u308b\u306b\u306f\u3001\u95a2\u6570\u3068\u540c\u69d8\u306b\u547c\u3073\u51fa\u3057\u307e\u3059 Kotlin\u306b\u306f<span style=\"color: #0000ff\"><strong>new\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u306a\u3044<\/strong><\/span>\u305f\u3081\u306b\u3001\u3053\u3046\u3044\u3063\u305f\u66f8\u304d\u65b9\u306b\u306a\u308a\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px\"><code>        \/\/\u30d7\u30e9\u30a4\u30de\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\r\n        val a = Any(\"a\")\r\n        \/\/\u30bb\u30ab\u30f3\u30c0\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\r\n        val b = Any(10, \"b\")\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u4f8b\u3048\u3070\u3001Any\u30af\u30e9\u30b9\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u95a2\u6570\u304c\u3042\u308b\u3068\u3059\u308c\u3070\u3001a.print\u3084b.print\u3067\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059<\/p>\n<pre style=\"border: dashed #000000 2px\"><code>    fun print(){\r\n        println(any_name)\r\n    }\r\n<\/code><\/pre>\n<h3>\u7d42\u308f\u308a\u306b<\/h3>\n<p>\u805e\u3044\u305f\u3053\u3068\u304c\u306a\u3044\u3088\u3046\u306a\u7528\u8a9e\u304c\u3042\u3063\u305f\u308a\u3001\u3068\u3053\u308d\u3069\u3053\u308dJava\u306e\u65b9\u304c\u7c21\u5358\u306b\u66f8\u3051\u308b\u3068\u601d\u3044\u307e\u3057\u305f\u304c\u3001\u6163\u308c\u306a\u3069\u306e\u554f\u984c\u3082\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u3053\u308c\u304b\u3089\u3082Kotlin\u3092\u4f7f\u7528\u3057\u3066\u4fbf\u5229\u306a\u3068\u3053\u308d\u3068\u3001\u4e0d\u4fbf\u306a\u3068\u3053\u308d\u3092\u898b\u6975\u3081\u305f\u3044\u3067\u3059<\/p>\n<p>\u706b\u66dc\u65e5\u62c5\u5f53:poppy<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5772\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/5772\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"AndroidStudio\u3067Kotlin\u3092\u4f7f\u7528(2)\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5772\" data-text=\"AndroidStudio\u3067Kotlin\u3092\u4f7f\u7528(2)\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5772\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/5772\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306fKotlin\u306b\u304a\u3051\u308b\u3001\u30af\u30e9\u30b9\u306b\u3064\u3044\u3066\u89e6\u308c\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100,119,12],"tags":[56,79,120],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/5772"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=5772"}],"version-history":[{"count":11,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/5772\/revisions"}],"predecessor-version":[{"id":5784,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/5772\/revisions\/5784"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=5772"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=5772"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=5772"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}