{"id":440,"date":"2023-04-02T22:07:00","date_gmt":"2023-04-02T13:07:00","guid":{"rendered":"https:\/\/baitimedx.com\/?p=440"},"modified":"2023-04-02T22:07:02","modified_gmt":"2023-04-02T13:07:02","slug":"android%e3%82%a2%e3%83%97%e3%83%aa%e3%82%92%e4%bd%9c%e3%82%8b%ef%bc%9fkotlin%e5%85%a5%e9%96%80-%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5%e3%81%a8%e3%83%87%e3%83%bc%e3%82%bf%e6%a7%8b%e9%80%a0%e3%81%ab","status":"publish","type":"post","link":"https:\/\/baitimedx.com\/?p=440","title":{"rendered":"Android\u30a2\u30d7\u30ea\u3092\u4f5c\u308b\uff1fKotlin\u5165\u9580 - \u57fa\u672c\u6982\u5ff5\u3068\u30c7\u30fc\u30bf\u69cb\u9020\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"724\" src=\"https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/04\/mobile-1087845_1280-1024x724.jpg\" alt=\"\" class=\"wp-image-441\" srcset=\"https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/04\/mobile-1087845_1280-1024x724.jpg 1024w, https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/04\/mobile-1087845_1280-300x212.jpg 300w, https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/04\/mobile-1087845_1280-768x543.jpg 768w, https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/04\/mobile-1087845_1280.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Kotlin\u306f\u30012011\u5e74\u306bJetBrains\u793e\u304c\u958b\u767a\u3057\u305f\u9759\u7684\u578b\u4ed8\u3051\u3055\u308c\u305f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3001Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306e\u305f\u3081\u306b\u7279\u306b\u6ce8\u76ee\u3055\u308c\u3066\u3044\u307e\u3059\u3002Java\u3068\u306e\u4e92\u63db\u6027\u304c\u3042\u308a\u3001\u3088\u308a\u7c21\u6f54\u3067\u5b89\u5168\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4eca\u56de\u306f\u3001Kotlin\u306e\u57fa\u790e\u306b\u3064\u3044\u3066\u3001\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Kotlin\u306e\u57fa\u672c\u69cb\u6587<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u5909\u6570<\/h3>\n\n\n\n<p>Kotlin\u3067\u306f\u3001\u5909\u6570\u3092\u5ba3\u8a00\u3059\u308b\u969b\u306b<code>val<\/code>\u3068<code>var<\/code>\u306e2\u3064\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u304c\u3042\u308a\u307e\u3059\u3002<code>val<\/code>\u306f\u8aad\u307f\u53d6\u308a\u5c02\u7528\u306e\u5909\u6570\u3067\u3001<code>var<\/code>\u306f\u8aad\u307f\u66f8\u304d\u304c\u53ef\u80fd\u306a\u5909\u6570\u3067\u3059\u3002\u578b\u63a8\u8ad6\u304c\u3042\u308b\u305f\u3081\u3001\u578b\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val name: String = \"John Doe\" \/\/ \u8aad\u307f\u53d6\u308a\u5c02\u7528\u5909\u6570\nvar age: Int = 25 \/\/ \u8aad\u307f\u66f8\u304d\u53ef\u80fd\u306a\u5909\u6570<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u95a2\u6570<\/h3>\n\n\n\n<p>\u95a2\u6570\u306f<code>fun<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u5f15\u6570\u306f\u5909\u6570\u540d\u306e\u5f8c\u306b\u30b3\u30ed\u30f3\u3092\u3064\u3051\u3066\u578b\u3092\u6307\u5b9a\u3057\u3001\u95a2\u6570\u306e\u623b\u308a\u5024\u306e\u578b\u306f\u3001\u5f15\u6570\u30ea\u30b9\u30c8\u306e\u5f8c\u306b\u30b3\u30ed\u30f3\u3092\u3064\u3051\u3066\u6307\u5b9a\u3057\u307e\u3059\u3002\u623b\u308a\u5024\u304c\u306a\u3044\u5834\u5408\u306f\u3001<code>Unit<\/code>\u578b\u3092\u6307\u5b9a\u3059\u308b\u304b\u3001\u7701\u7565\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>fun greet(name: String): String {\n    return \"Hello, $name!\"\n}\n\nfun displayAge(age: Int) {\n    println(\"Your age is $age.\")\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6761\u4ef6\u5f0f<\/h3>\n\n\n\n<p>Kotlin\u3067\u306f\u3001<code>if<\/code>\u3068<code>else<\/code>\u3092\u4f7f\u3063\u305f\u6761\u4ef6\u5f0f\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u6761\u4ef6\u5f0f\u306f\u5024\u3092\u8fd4\u3059\u305f\u3081\u3001\u4e09\u9805\u6f14\u7b97\u5b50\u306e\u4ee3\u308f\u308a\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val age = 18\nval status = if (age >= 18) \"adult\" else \"minor\"\nprintln(\"You are a $status.\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7e70\u308a\u8fd4\u3057\u51e6\u7406<\/h3>\n\n\n\n<p>Kotlin\u3067\u306f\u3001<code>for<\/code>\u30eb\u30fc\u30d7\u3068<code>while<\/code>\u30eb\u30fc\u30d7\u3092\u4f7f\u3063\u3066\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>for (i in 1..5) {\n    println(\"Hello, Kotlin! $i\")\n}\n\nvar count = 5\nwhile (count > 0) {\n    println(\"Countdown: $count\")\n    count--\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Kotlin\u306e\u57fa\u672c\u30c7\u30fc\u30bf\u578b<\/h2>\n\n\n\n<p>Kotlin\u306b\u306f\u3001\u6570\u5024\u3001\u6587\u5b57\u3001\u6587\u5b57\u5217\u3001\u30d6\u30fc\u30eb\u5024\u306a\u3069\u306e\u57fa\u672c\u30c7\u30fc\u30bf\u578b\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6570\u5024<\/h3>\n\n\n\n<p>\u6570\u5024\u578b\u306b\u306f\u3001<code>Int<\/code>\u3001<code>Long<\/code>\u3001<code>Float<\/code>\u3001<code>Double<\/code>\u3001<code>Short<\/code>\u3001<code>Byte<\/code>\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002\u578b\u3092\u660e\u793a\u7684\u306b\u6307\u5b9a\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u30b3\u30f3\u30d1\u30a4\u30e9\u304c\u9069\u5207\u306a\u578b\u3092\u63a8\u8ad6\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val intNumber: Int = 42\nval longNumber: Long = 42L\nval floatNumber: Float = 42.0f\nval doubleNumber: Double = 42.0<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u6587\u5b57\u3068\u6587\u5b57\u5217<\/h3>\n\n\n\n<p><code>Char<\/code>\u578b\u306f\u3001\u5358\u4e00\u306e\u6587\u5b57\u3092\u8868\u3057\u307e\u3059\u3002\u6587\u5b57\u306f\u30b7\u30f3\u30b0\u30eb\u30af\u30a9\u30fc\u30c8\u3067\u56f2\u307e\u308c\u3066\u3044\u307e\u3059\u3002<code>String<\/code>\u578b\u306f\u3001\u6587\u5b57\u5217\u3092\u8868\u3057\u3001\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c8\u3067\u56f2\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val letter: Char = 'A'\nval message: String = \"Hello, Kotlin!\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d6\u30fc\u30eb\u5024<\/h3>\n\n\n\n<p>\u30d6\u30fc\u30eb\u5024\u306f<code>Boolean<\/code>\u578b\u3067\u3001<code>true<\/code>\u307e\u305f\u306f<code>false<\/code>\u306e\u5024\u3092\u6301\u3061\u307e\u3059\u3002\u30d6\u30fc\u30eb\u5024\u306f\u3001\u8ad6\u7406\u6f14\u7b97\u3084\u6761\u4ef6\u5224\u65ad\u306b\u4f7f\u7528\u3055\u308c\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5236\u5fa1\u30d5\u30ed\u30fc\u3092\u6c7a\u5b9a\u3059\u308b\u305f\u3081\u306b\u91cd\u8981\u306a\u5f79\u5272\u3092\u679c\u305f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val isTrue: Boolean = true\nval isFalse: Boolean = false<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b3\u30ec\u30af\u30b7\u30e7\u30f3<\/h2>\n\n\n\n<p>Kotlin\u3067\u306f\u3001\u30ea\u30b9\u30c8\u3001\u30bb\u30c3\u30c8\u3001\u30de\u30c3\u30d7\u306a\u3069\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ea\u30b9\u30c8<\/h3>\n\n\n\n<p>\u30ea\u30b9\u30c8\u306f\u3001\u9806\u5e8f\u4ed8\u3051\u3089\u308c\u305f\u8981\u7d20\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u3059\u3002<code>listOf<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30ea\u30b9\u30c8\u306f\u5909\u66f4\u4e0d\u53ef\u80fd\uff08\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\uff09\u3067\u3059\u304c\u3001<code>mutableListOf<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u5909\u66f4\u53ef\u80fd\uff08\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\uff09\u306a\u30ea\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val immutableList = listOf(1, 2, 3)\nval mutableList = mutableListOf(1, 2, 3)\nmutableList.add(4)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30bb\u30c3\u30c8<\/h3>\n\n\n\n<p>\u30bb\u30c3\u30c8\u306f\u3001\u91cd\u8907\u3057\u306a\u3044\u8981\u7d20\u306e\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u3059\u3002<code>setOf<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30bb\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30bb\u30c3\u30c8\u3082\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u3067\u3059\u304c\u3001<code>mutableSetOf<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30bb\u30c3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val immutableSet = setOf(1, 2, 3, 3)\nval mutableSet = mutableSetOf(1, 2, 3)\nmutableSet.add(4)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30de\u30c3\u30d7\u306e\u57fa\u672c<\/h2>\n\n\n\n<p>\u30de\u30c3\u30d7\u306f\u3001\u30ad\u30fc\u3068\u5024\u306e\u30da\u30a2\u3067\u69cb\u6210\u3055\u308c\u308b\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3067\u3001\u30ad\u30fc\u3092\u4f7f\u3063\u3066\u5024\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002Kotlin\u3067\u306f\u3001<code>Map<\/code>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30fc\u30b9\u3092\u5b9f\u88c5\u3057\u305f\u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u30de\u30c3\u30d7\u3092\u8868\u73fe\u3057\u307e\u3059\u3002\u4e3b\u306b\u3001<code>HashMap<\/code>\u3001<code>LinkedHashMap<\/code>\u3001<code>SortedMap<\/code>\u3001<code>TreeMap<\/code>\u306a\u3069\u306e\u5b9f\u88c5\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u901a\u5e38\u306f<code>mapOf<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30de\u30c3\u30d7\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30de\u30c3\u30d7\u306e\u4f5c\u6210<\/h3>\n\n\n\n<p>\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30de\u30c3\u30d7\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001<code>mapOf<\/code>\u95a2\u6570\u3092\u4f7f\u3044\u307e\u3059\u3002\u30ad\u30fc\u3068\u5024\u306e\u30da\u30a2\u3092<code>to<\/code>\u6f14\u7b97\u5b50\u3092\u4f7f\u3063\u3066\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val map = mapOf(\"one\" to 1, \"two\" to 2, \"three\" to 3)\nprintln(map) \/\/ {one=1, two=2, three=3}<\/code><\/pre>\n\n\n\n<p>\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30de\u30c3\u30d7\u3092\u4f5c\u6210\u3059\u308b\u306b\u306f\u3001<code>mutableMapOf<\/code>\u95a2\u6570\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val mutableMap = mutableMapOf(\"one\" to 1, \"two\" to 2, \"three\" to 3)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8981\u7d20\u306e\u8ffd\u52a0\u3068\u524a\u9664<\/h3>\n\n\n\n<p>\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30de\u30c3\u30d7\u3067\u306f\u3001\u8981\u7d20\u3092\u8ffd\u52a0\u3057\u305f\u308a\u524a\u9664\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u8981\u7d20\u3092\u8ffd\u52a0\u3059\u308b\u306b\u306f\u3001<code>put<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u304b\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u6f14\u7b97\u5b50\uff08<code>[]<\/code>\uff09\u3092\u4f7f\u3063\u3066\u30ad\u30fc\u306b\u5bfe\u5fdc\u3059\u308b\u5024\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mutableMap.put(\"four\", 4)\nmutableMap[\"five\"] = 5\nprintln(mutableMap) \/\/ {one=1, two=2, three=3, four=4, five=5}<\/code><\/pre>\n\n\n\n<p>\u8981\u7d20\u3092\u524a\u9664\u3059\u308b\u306b\u306f\u3001<code>remove<\/code>\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u3001\u524a\u9664\u3057\u305f\u3044\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mutableMap.remove(\"one\")\nprintln(mutableMap) \/\/ {two=2, three=3, four=4, five=5}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8981\u7d20\u3078\u306e\u30a2\u30af\u30bb\u30b9<\/h3>\n\n\n\n<p>\u30de\u30c3\u30d7\u304b\u3089\u8981\u7d20\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u306b\u306f\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u6f14\u7b97\u5b50\uff08<code>[]<\/code>\uff09\u3092\u4f7f\u3063\u3066\u30ad\u30fc\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u30ad\u30fc\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u3001<code>null<\/code>\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val value = map[\"two\"]\nprintln(value) \/\/ 2<\/code><\/pre>\n\n\n\n<p>\u30ad\u30fc\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8fd4\u3059\u306b\u306f\u3001<code>getOrElse<\/code>\u95a2\u6570\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val defaultValue = map.getOrElse(\"unknown\") { -1 }\nprintln(defaultValue) \/\/ -1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30de\u30c3\u30d7\u306e\u53cd\u5fa9\u51e6\u7406<\/h2>\n\n\n\n<p>\u30de\u30c3\u30d7\u306b\u5bfe\u3059\u308b\u53cd\u5fa9\u51e6\u7406\u306f\u3001\u30de\u30c3\u30d7\u306e\u5404\u30a8\u30f3\u30c8\u30ea\uff08\u30ad\u30fc\u3068\u5024\u306e\u30da\u30a2\uff09\u306b\u5bfe\u3057\u3066\u64cd\u4f5c\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002Kotlin\u3067\u306f\u3001\u3055\u307e\u3056\u307e\u306a\u65b9\u6cd5\u3067\u30de\u30c3\u30d7\u306e\u53cd\u5fa9\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">for\u30eb\u30fc\u30d7\u3092\u4f7f\u3063\u305f\u53cd\u5fa9\u51e6\u7406<\/h3>\n\n\n\n<p><code>for<\/code>\u30eb\u30fc\u30d7\u3092\u4f7f\u3063\u3066\u30de\u30c3\u30d7\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u53cd\u5fa9\u51e6\u7406\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30c7\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u30ea\u30f3\u30b0\u5ba3\u8a00\u3092\u5229\u7528\u3057\u3066\u3001\u30ad\u30fc\u3068\u5024\u3092\u5225\u3005\u306e\u5909\u6570\u306b\u4ee3\u5165\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>val map = mapOf(\"one\" to 1, \"two\" to 2, \"three\" to 3)\n\nfor ((key, value) in map) {\n    println(\"$key = $value\")\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">forEach\u95a2\u6570\u3092\u4f7f\u3063\u305f\u53cd\u5fa9\u51e6\u7406<\/h3>\n\n\n\n<p><code>forEach<\/code>\u95a2\u6570\u3092\u4f7f\u3063\u3066\u3001\u30de\u30c3\u30d7\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u53cd\u5fa9\u51e6\u7406\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30e9\u30e0\u30c0\u5f0f\u3092\u5f15\u6570\u3068\u3057\u3066\u53d7\u3051\u53d6\u308a\u3001\u30a8\u30f3\u30c8\u30ea\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30c7\u30b9\u30c8\u30e9\u30af\u30c1\u30e3\u30ea\u30f3\u30b0\u5ba3\u8a00\u3092\u4f7f\u7528\u3057\u3066\u3001\u30ad\u30fc\u3068\u5024\u3092\u5225\u3005\u306e\u5909\u6570\u306b\u4ee3\u5165\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>map.forEach { (key, value) ->\n    println(\"$key = $value\")\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">keys\u3068values\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u3063\u305f\u53cd\u5fa9\u51e6\u7406<\/h3>\n\n\n\n<p>\u30de\u30c3\u30d7\u306e\u30ad\u30fc\u3060\u3051\u3092\u53cd\u5fa9\u51e6\u7406\u3059\u308b\u5834\u5408\u3001<code>keys<\/code>\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u30de\u30c3\u30d7\u5185\u306e\u3059\u3079\u3066\u306e\u30ad\u30fc\u3092\u542b\u3080\u30bb\u30c3\u30c8\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>for (key in map.keys) {\n    println(\"Key: $key\")\n}<\/code><\/pre>\n\n\n\n<p>\u540c\u69d8\u306b\u3001\u30de\u30c3\u30d7\u306e\u5024\u3060\u3051\u3092\u53cd\u5fa9\u51e6\u7406\u3059\u308b\u5834\u5408\u3001<code>values<\/code>\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002\u3053\u308c\u306f\u3001\u30de\u30c3\u30d7\u5185\u306e\u3059\u3079\u3066\u306e\u5024\u3092\u542b\u3080\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>for (value in map.values) {\n    println(\"Value: $value\")\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u7d99\u627f<\/h3>\n\n\n\n<p>Kotlin\u3067\u306f\u3001\u30af\u30e9\u30b9\u306e\u7d99\u627f\u3092\u4f7f\u3063\u3066\u3001\u65e2\u5b58\u306e\u30af\u30e9\u30b9\u304b\u3089\u65b0\u3057\u3044\u30af\u30e9\u30b9\u3092\u6d3e\u751f\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>open<\/code>\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u3063\u3066\u7d99\u627f\u53ef\u80fd\u306a\u30af\u30e9\u30b9\u3092\u5ba3\u8a00\u3057\u3001<code>:<\/code>\u3092\u4f7f\u3063\u3066\u7d99\u627f\u3092\u8868\u73fe\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>open class Animal(val name: String) {\n    fun makeSound() {\n        println(\"$name makes a sound.\")\n    }\n}\n\nclass Dog(name: String) : Animal(name) {\n    override fun makeSound() {\n        println(\"$name barks.\")\n    }\n}\n\nval dog = Dog(\"Buddy\")\ndog.makeSound()<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u62e1\u5f35\u95a2\u6570<\/h2>\n\n\n\n<p>Kotlin\u3067\u306f\u3001\u65e2\u5b58\u306e\u30af\u30e9\u30b9\u306b\u65b0\u3057\u3044\u95a2\u6570\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u62e1\u5f35\u95a2\u6570\u3068\u3044\u3046\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30af\u30e9\u30b9\u306e\u30b3\u30fc\u30c9\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u306a\u304f\u3001\u65b0\u3057\u3044\u6a5f\u80fd\u3092\u8ffd\u52a0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>fun String.upperFirst(): String {\n    return this[0].toUpperCase() + this.substring(1)\n}\n\nval name = \"john\"\nval capitalized = name.upperFirst()\nprintln(capitalized) \/\/ \"John\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u4eca\u56de\u306f\u3001Kotlin\u306e\u57fa\u672c\u69cb\u6587\u3084\u30c7\u30fc\u30bf\u578b\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u3001\u30af\u30e9\u30b9\u3001\u62e1\u5f35\u95a2\u6570\u306a\u3069\u306b\u3064\u3044\u3066\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002Kotlin\u306f\u3001Java\u3068\u306e\u4e92\u63db\u6027\u304c\u3042\u308a\u306a\u304c\u3089\u3001\u3088\u308a\u7c21\u6f54\u3067\u8868\u73fe\u529b\u8c4a\u304b\u306a\u8a00\u8a9e\u3067\u3042\u308b\u305f\u3081\u3001\u958b\u767a\u8005\u306b\u3068\u3063\u3066\u9b45\u529b\u7684\u306a\u9078\u629e\u80a2\u306e\u4e00\u3064\u3067\u3059\u3002\u3053\u308c\u304b\u3089\u3082Kotlin\u3092\u5b66\u3076\u304d\u3063\u304b\u3051\u306b\u306a\u308c\u308b\u3068\u5e78\u3044\u3067\u3059\uff01<\/p>\n\n\n\n<p>\u4eca\u5f8c\u3082\u3001IT\u3084DX\u3001\u6295\u8cc7\u7b49\u306b\u95a2\u3059\u308b\u4eba\u751f\u3092\u8c4a\u304b\u306b\u3057\u3066\u81ea\u7531\u306a\u6642\u9593\u3092\u5897\u3084\u305b\u308b\u3088\u3046\u306a\u60c5\u5831\u3092\u767a\u4fe1\u3057\u3066\u3044\u304d\u307e\u3059\u306e\u3067\u662f\u975e\u304a\u697d\u3057\u307f\u306b\uff01<\/p>\n\n\n\n<p><strong>\u2193\u3000\u30aa\u30b9\u30b9\u30e1\u8a18\u4e8b\u3000\u2193<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/baitimedx.com\/?p=436\">\u4e00\u756a\u30aa\u30fc\u30eb\u30de\u30a4\u30c6\u30a3\u306a\u8a00\u8a9e\uff1fJava\u306e\u57fa\u790e- \u30c7\u30fc\u30bf\u578b\u304b\u3089\u30af\u30e9\u30b9\u3001\u4f8b\u5916\u51e6\u7406\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/baitimedx.com\/?p=432\">\u30b5\u30a4\u30c8\u306e\u5916\u89b3\u3092\u6c7a\u3081\u308b\u8a00\u8a9e\uff1fCSS\u5165\u9580 &#8211; \u57fa\u672c\u6982\u5ff5\u3068\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/baitimedx.com\/?p=429\">\u5fc5\u9808\u306e\u8a00\u8a9e\uff1fHTML\u5165\u9580 &#8211; \u30a6\u30a7\u30d6\u30da\u30fc\u30b8\u69cb\u7bc9\u306e\u57fa\u672c\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kotlin\u306f\u30012011\u5e74\u306bJetBrains\u793e\u304c\u958b\u767a\u3057\u305f\u9759\u7684\u578b\u4ed8\u3051\u3055\u308c\u305f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3067\u3001Android\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u958b\u767a\u306e\u305f\u3081\u306b\u7279\u306b\u6ce8\u76ee\u3055\u308c\u3066\u3044\u307e\u3059\u3002Java\u3068\u306e\u4e92\u63db\u6027\u304c\u3042\u308a\u3001\u3088\u308a\u7c21\u6f54\u3067\u5b89\u5168 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":441,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[10],"tags":[24,17,16],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/baitimedx.com\/wp-content\/uploads\/2023\/04\/mobile-1087845_1280.jpg","_links":{"self":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts\/440"}],"collection":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=440"}],"version-history":[{"count":1,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts\/440\/revisions"}],"predecessor-version":[{"id":442,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/posts\/440\/revisions\/442"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=\/wp\/v2\/media\/441"}],"wp:attachment":[{"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/baitimedx.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}