{"id":483,"date":"2023-12-26T04:25:39","date_gmt":"2023-05-03T14:30:28","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/index.php\/2023\/11\/30\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/"},"modified":"2025-08-02T12:59:26","modified_gmt":"2025-08-02T04:59:26","slug":"kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/","title":{"rendered":"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357"},"content":{"rendered":"<p>Kotlin\u662f\u4e00\u79cd\u6700\u65b0\u7684JVM\u7f16\u7a0b\u8bed\u8a00\uff0c\u7531JetBrains\u63a8\u51fa\u3002\u8c37\u6b4c\u5c06\u5176\u4e0eJava\u4e00\u540c\u8bbe\u5b9a\u4e3aAndroid\u5f00\u53d1\u7684\u5b98\u65b9\u8bed\u8a00\u3002\u5f00\u53d1\u8005\u8868\u793a\uff0c\u5b83\u89e3\u51b3\u4e86Java\u7f16\u7a0b\u4e2d\u6240\u9047\u5230\u7684\u95ee\u9898\u3002\u6211\u5199\u4e86\u5f88\u591a\u5173\u4e8eKotlin\u7684\u6559\u7a0b\uff0c\u8fd9\u91cc\u6211\u5c06\u63d0\u4f9b\u4e00\u4e9b\u91cd\u8981\u7684Kotlin\u9762\u8bd5\u95ee\u9898\u3002<\/p>\n<h2>Kotlin\u9762\u8bd5\u95ee\u9898\u5728\u8fd9\u91cc\uff0c\u6211\u63d0\u4f9b\u4e86\u4e00\u4e9b Kotlin \u9762\u8bd5\u95ee\u9898\u548c\u7b54\u6848\uff0c\u8fd9\u5c06\u5e2e\u52a9\u4f60\u51c6\u5907 Kotlin \u9762\u8bd5\u3002 \u8fd9\u4e9b Kotlin \u9762\u8bd5\u95ee\u9898\u9002\u7528\u4e8e\u521d\u5b66\u8005\u548c\u6709\u7ecf\u9a8c\u7684\u7a0b\u5e8f\u5458\u3002\u8fd8\u6709\u7f16\u7a0b\u95ee\u9898\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u63d0\u5347\u7f16\u7801\u80fd\u529b\u3002<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>Kotlin\u4e2dKotlinJVM\u662f\u76ee\u6807\u5e73\u53f0\u3002\u7531\u4e8eJava\u865a\u62df\u673a(JVM)\u662fKotlin\u7684\u76ee\u6807\u5e73\u53f0\uff0c\u56e0\u6b64Kotlin\u4e0eJava\u5177\u6709100\uff05\u7684\u4e92\u64cd\u4f5c\u6027\u3002\u7f16\u8bd1\u540e\u90fd\u4f1a\u751f\u6210\u5b57\u8282\u7801\uff0c\u6240\u4ee5\u53ef\u4ee5\u4eceJava\u8c03\u7528Kotlin\u4ee3\u7801\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002<\/ol>\n<\/li>\n<\/ol>\n<p>\u5728Kotlin\u4e2d\uff0c\u53d8\u91cf\u7684\u58f0\u660e\u6709\u4e24\u4e2a\u4e3b\u8981\u533a\u522b\u4e0eJava\uff1a<\/p>\n<p>1. \u58f0\u660e\u7684\u7c7b\u578b\u3002\u5728Java\u4e2d\uff0c\u58f0\u660e\u5982\u4e0b\uff1a<br \/>\nString s = &#8220;Java String&#8221;;<br \/>\nint x = 10;<\/p>\n<p>\u5728Kotlin\u4e2d\uff0c\u58f0\u660e\u5982\u4e0b\uff1a<br \/>\nval s: String = &#8220;Hi&#8221;<br \/>\nvar x = 5<\/p>\n<p>Kotlin\u7684\u58f0\u660e\u4ee5val\u548cvar\u5f00\u59cb\uff0c\u4e4b\u540e\u662f\u53ef\u9009\u7684\u7c7b\u578b\u3002Kotlin\u53ef\u4ee5\u4f7f\u7528\u7c7b\u578b\u63a8\u65ad\u81ea\u52a8\u68c0\u6d4b\u7c7b\u578b\u3002<\/p>\n<p>2. \u9ed8\u8ba4\u503c\u3002\u5728Java\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u65b9\u5f0f\uff1a<br \/>\nString s;<\/p>\n<p>\u5728Kotlin\u4e2d\uff0c\u4ee5\u4e0b\u53d8\u91cf\u58f0\u660e\u662f\u65e0\u6548\u7684\uff1a<br \/>\nval s: String<\/p>\n<p>val\u53d8\u91cf\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u7c7b\u4f3c\u4e8eJava\u4e2d\u7684final\u4fee\u9970\u7b26\u3002var\u53d8\u91cf\u53ef\u4ee5\u91cd\u65b0\u8d4b\u503c\uff0c\u4f46\u91cd\u65b0\u8d4b\u503c\u7684\u503c\u5fc5\u987b\u662f\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\u3002\u6211\u4eec\u4f7f\u7528toInt()\u65b9\u6cd5\u5c06String\u8f6c\u6362\u4e3aInt\u3002<\/p>\n<p>Kotlin\u975e\u5e38\u6ce8\u91cd\u7a7a\u5b89\u5168\uff0c\u8be5\u7279\u6027\u7528\u4e8e\u9632\u6b62\u4ee4\u4eba\u6076\u5fc3\u7684\u7a7a\u6307\u9488\u5f02\u5e38\u3002Kotlin\u4f7f\u7528\u53ef\u7a7a\u7c7b\u578b\uff08\u4f8b\u5982String?\u3001Int?\u3001Float?\u7b49\uff09\u6765\u5b9e\u73b0\u7a7a\u5b89\u5168\u3002\u53ef\u7a7a\u7c7b\u578b\u8d77\u5230\u4e86\u5305\u88c5\u7c7b\u578b\u7684\u4f5c\u7528\uff0c\u53ef\u4ee5\u5305\u542bnull\u503c\u3002\u53ef\u7a7a\u503c\u4e0d\u80fd\u6dfb\u52a0\u5230\u53e6\u4e00\u4e2a\u53ef\u7a7a\u503c\u6216\u57fa\u672c\u7c7b\u578b\u503c\u4e2d\u3002\u8981\u83b7\u53d6\u57fa\u672c\u7c7b\u578b\u503c\uff0c\u6211\u4eec\u9700\u8981\u4f7f\u7528\u5b89\u5168\u8c03\u7528\u6765\u53d6\u6d88\u5305\u88c5\u53ef\u7a7a\u7c7b\u578b\u3002\u5982\u679c\u5728\u53d6\u6d88\u5305\u88c5\u65f6\uff0c\u503c\u4e3anull\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u5ffd\u7565\u6216\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002Elvis\u8fd0\u7b97\u7b26\u7528\u4e8e\u5b89\u5168\u53d6\u6d88\u5305\u88c5Nullable\u503c\uff0c\u8868\u793a\u4e3a?:\u3002\u5982\u679cNullable\u7c7b\u578b\u4e3anull\uff0c\u5219\u4f7f\u7528\u53f3\u4fa7\u7684\u503c\u3002<\/p>\n<p>const\u662f\u7f16\u8bd1\u65f6\u5e38\u91cf\uff0cval\u5c5e\u6027\u9ed8\u8ba4\u662f\u5728\u8fd0\u884c\u65f6\u8bbe\u7f6e\u7684\u3002const\u4e0d\u80fd\u4e0evar\u4e00\u8d77\u4f7f\u7528\uff0c\u4e5f\u4e0d\u80fd\u5355\u72ec\u4f7f\u7528\u3002const\u4e0d\u9002\u7528\u4e8e\u5c40\u90e8\u53d8\u91cf\u3002<\/p>\n<p>\u5728\u8bed\u8a00\u7ea7\u522b\uff0cKotlin\u4e0d\u5141\u8bb8\u76f4\u63a5\u4f7f\u7528int\u3001float\u3001double\u7b49\u539f\u59cb\u7c7b\u578b\u3002\u4f46\u662f\uff0c\u7f16\u8bd1\u751f\u6210\u7684JVM\u5b57\u8282\u7801\u786e\u5b9e\u5305\u542b\u8fd9\u4e9b\u7c7b\u578b\u3002<\/p>\n<p>\u6bcf\u4e2aKotlin\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9\u662fmain\u51fd\u6570\u3002\u5728Kotlin\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u4e0d\u5728\u7c7b\u4e2d\u7f16\u5199main\u51fd\u6570\u3002\u5728\u7f16\u8bd1\u65f6\uff0cJVM\u4f1a\u9690\u5f0f\u5c01\u88c5\u5b83\u5728\u4e00\u4e2a\u7c7b\u4e2d\u3002\u4ee5Array\u5f62\u5f0f\u4f20\u9012\u7684\u5b57\u7b26\u4e32\u7528\u4e8e\u68c0\u7d22\u547d\u4ee4\u884c\u53c2\u6570\u3002<\/p>\n<p>!!\u7528\u4e8e\u5f3a\u5236\u53d6\u6d88\u5305\u88c5\u53ef\u7a7a\u7c7b\u578b\u4ee5\u83b7\u53d6\u503c\u3002\u5982\u679c\u8fd4\u56de\u7684\u503c\u4e3anull\uff0c\u5c06\u5bfc\u81f4\u8fd0\u884c\u65f6\u9519\u8bef\u3002\u56e0\u6b64\uff0c!!\u64cd\u4f5c\u7b26\u53ea\u5e94\u5728\u786e\u5b9a\u503c\u7edd\u5bf9\u4e0d\u4f1a\u4e3anull\u65f6\u4f7f\u7528\u3002\u5426\u5219\uff0c\u5c06\u4f1a\u51fa\u73b0\u4ee4\u4eba\u6050\u6016\u7684\u7a7a\u6307\u9488\u5f02\u5e38\u3002\u53e6\u4e00\u65b9\u9762\uff0c?.\u662fElvis\u8fd0\u7b97\u7b26\uff0c\u7528\u4e8e\u8fdb\u884c\u5b89\u5168\u8c03\u7528\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528lambda\u8868\u8fbe\u5f0flet\u6765\u5b89\u5168\u53d6\u6d88\u5305\u88c5\u53ef\u7a7a\u7c7b\u578b\u3002\u8fd9\u91cc\u7684let\u8868\u8fbe\u5f0f\u5bf9\u53ef\u7a7a\u7c7b\u578b\u8fdb\u884c\u5b89\u5168\u8c03\u7528\u89e3\u9664\u5305\u88c5\u3002<\/p>\n<p>\u51fd\u6570\u7684\u58f0\u660e\u5982\u4e0b\u6240\u793a\uff1a<br \/>\nfun sumOf(a: Int, b: Int): Int{<br \/>\nreturn a + b<br \/>\n}<\/p>\n<p>\u51fd\u6570\u7684\u8fd4\u56de\u7c7b\u578b\u5728\u5192\u53f7\u540e\u5b9a\u4e49\u3002\u5728Kotlin\u4e2d\uff0c\u51fd\u6570\u53ef\u4ee5\u5728Kotlin\u6587\u4ef6\u7684\u6839\u90e8\u58f0\u660e\u3002\u56e0\u6b64\uff0c\u5b83\u4eec\u88ab\u79f0\u4e3a\u9876\u5c42\u51fd\u6570\u3002<\/p>\n<p>\u5728Kotlin\u4e2d\uff0c==\u64cd\u4f5c\u7b26\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u5bf9\u8c61\u7684\u5185\u5bb9\u662f\u5426\u76f8\u7b49\uff0c===\u64cd\u4f5c\u7b26\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u5bf9\u8c61\u7684\u5f15\u7528\u662f\u5426\u76f8\u7b49\u3002<\/p>\n<pre class=\"post-pre\"><code>\\== is used to compare the values are equal or not. === is used to check if the references are equal or not.\r\n<\/code><\/pre>\n<ol>\u5217\u51fa Kotlin \u4e2d\u53ef\u7528\u7684\u53ef\u89c1\u6027\u4fee\u9970\u7b26\u3002\u9ed8\u8ba4\u7684\u53ef\u89c1\u6027\u4fee\u9970\u7b26\u662f\u4ec0\u4e48\uff1f<\/ol>\n<pre class=\"post-pre\"><code>-   public\r\n-   internal\r\n-   protected\r\n-   private\r\n\r\n`public` is the default visibility modifier.\r\n<\/code><\/pre>\n<ol>\u4ee5\u4e0b\u7ee7\u627f\u7ed3\u6784\u662f\u5426\u7f16\u8bd1\u901a\u8fc7\uff1f<\/ol>\n<pre class=\"post-pre\"><code>```\r\nclass A{\r\n}\r\n\r\nclass B : A(){\r\n\r\n}\r\n```\r\n\r\n**NO**. By default classes are final in Kotlin. To make them non-final, you need to add the `open` modifier.\r\n\r\n```\r\nopen class A{\r\n}\r\n\r\nclass B : A(){\r\n\r\n}\r\n```\r\n<\/code><\/pre>\n<ol>\u5728Kotlin\u4e2d\u6709\u54ea\u4e9b\u6784\u9020\u51fd\u6570\u7c7b\u578b\uff1f\u5b83\u4eec\u6709\u4f55\u4e0d\u540c\uff1f\u5982\u4f55\u5728\u7c7b\u4e2d\u5b9a\u4e49\u5b83\u4eec\uff1f<\/ol>\n<pre class=\"post-pre\"><code>Constructors in Kotlin are of two types: **Primary** - These are defined in the class headers. They cannot hold any logic. There's only one primary constructor per class. **Secondary** - They're defined in the class body. They must delegate to the primary constructor if it exists. They can hold logic. There can be more than one secondary constructors.\r\n\r\n```\r\nclass User(name: String, isAdmin: Boolean){\r\n\r\nconstructor(name: String, isAdmin: Boolean, age: Int) :this(name, isAdmin)\r\n{\r\n    this.age = age\r\n}\r\n\r\n}\r\n```\r\n<\/code><\/pre>\n<ol>Kotlin\u4e2d\u7684init\u5757\u662f\u4ec0\u4e48\u610f\u601d\uff1f<\/ol>\n<pre class=\"post-pre\"><code>`init` is the initialiser block in Kotlin. It's executed once the primary constructor is instantiated. If you invoke a secondary constructor, then it works after the primary one as it is composed in the chain.\r\n<\/code><\/pre>\n<ol>\u5728Kotlin\u4e2d\uff0c\u5b57\u7b26\u4e32\u63d2\u503c\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff1f\u8bf7\u7528\u4e00\u6bb5\u4ee3\u7801\u7247\u6bb5\u89e3\u91ca\u4e00\u4e0b\u3002<\/ol>\n<pre class=\"post-pre\"><code>String interpolation is used to evaluate string templates. We use the symbol $ to add variables inside a string.\r\n\r\n```\r\nval name = \"Journaldev.com\"\r\nval desc = \"$name now has Kotlin Interview Questions too. ${name.length}\"\r\n```\r\n\r\nUsing `{}` we can compute an expression too.\r\n<\/code><\/pre>\n<ol>\u6784\u9020\u51fd\u6570\u4e2d\u7684\u53c2\u6570\u7c7b\u578b\u662f\u4ec0\u4e48\uff1f<\/ol>\n<pre class=\"post-pre\"><code>By default, the constructor arguments are `val` unless explicitly set to `var`.\r\n<\/code><\/pre>\n<ol>\u5728Kotlin\u4e2d\uff0c&#8221;new&#8221;\u662f\u4e00\u4e2a\u5173\u952e\u5b57\u5417\uff1f\u4f60\u5982\u4f55\u5728Kotlin\u4e2d\u5b9e\u4f8b\u5316\u4e00\u4e2a\u7c7b\u5bf9\u8c61\uff1f<\/ol>\n<pre class=\"post-pre\"><code>**NO**. Unlike Java, in Kotlin, new isn't a keyword. We can instantiate a class in the following way:\r\n\r\n```\r\nclass A\r\nvar a = A()\r\nval new = A()\r\n```\r\n<\/code><\/pre>\n<ol>\u5728Kotlin\u4e2d\uff0cswitch\u8868\u8fbe\u5f0f\u7684\u7b49\u4ef7\u8bed\u6cd5\u662f\u4ec0\u4e48\uff1f\u5b83\u4e0eswitch\u6709\u4f55\u4e0d\u540c\u4e4b\u5904\uff1f<\/ol>\n<pre class=\"post-pre\"><code>when is the equivalent of `switch` in `Kotlin`. The default statement in a when is represented using the else statement.\r\n\r\n```\r\nvar num = 10\r\n    when (num) {\r\n        0..4 -&gt; print(\"value is 0\")\r\n        5 -&gt; print(\"value is 5\")\r\n        else -&gt; {\r\n            print(\"value is in neither of the above.\")\r\n        }\r\n    }\r\n```\r\n\r\n`when` statments have a default break statement in them.\r\n<\/code><\/pre>\n<ol>\u5728Kotlin\u4e2d\uff0c\u6570\u636e\u7c7b\u662f\u4ec0\u4e48\uff1f\u5b83\u4eec\u6709\u4ec0\u4e48\u7528\u5904\uff1f\u5b83\u4eec\u662f\u5982\u4f55\u5b9a\u4e49\u7684\uff1f<\/ol>\n<pre class=\"post-pre\"><code>In Java, to create a class that stores data, you need to set the variables, the getters and the setters, override the `toString()`, `hash()` and `copy()` functions. In Kotlin you just need to add the `data` keyword on the class and all of the above would automatically be created under the hood.\r\n\r\n```\r\ndata class Book(var name: String, var authorName: String)\r\n\r\nfun main(args: Array&lt;String&gt;) {\r\nval book = Book(\"Kotlin Tutorials\",\"Anupam\")\r\n}\r\n```\r\n\r\nThus, data classes saves us with lot of code. It creates component functions such as `component1()`.. `componentN()` for each of the variables. [![kotlin interview questions data classes](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-data-classes.png)](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-data-classes.png)\r\n<\/code><\/pre>\n<ol>\u8bf7\u7528\u4e00\u4e2a\u4f8b\u5b50\u6765\u89e3\u91ca\u4e00\u4e0bKotlin\u4e2d\u7684\u89e3\u6784\u58f0\u660e\u662f\u4ec0\u4e48\u610f\u601d\u3002<\/ol>\n<pre class=\"post-pre\"><code>Destructuring Declarations is a smart way to assign multiple values to variables from data stored in objects\/arrays. [![kotlin interview questions destructuring declarations](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-destructuring-declarations.png)](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-destructuring-declarations.png) Within paratheses, we've set the variable declarations. Under the hood, destructuring declarations create component functions for each of the class variables.\r\n<\/code><\/pre>\n<ol>\u5185\u8054\u51fd\u6570\u548c\u4e2d\u7f00\u51fd\u6570\u6709\u4ec0\u4e48\u533a\u522b\uff1f\u8bf7\u5206\u522b\u4e3e\u4f8b\u3002<\/ol>\n<pre class=\"post-pre\"><code>[Inline functions](\/community\/tutorials\/kotlin-inline-function-reified) are used to save us memory overhead by preventing object allocations for the anonymous functions\/lambda expressions called. Instead, it provides that functions body to the function that calls it at runtime. This increases the bytecode size slightly but saves us a lot of memory. [![kotlin interview questions inline functions](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-inline-functions.png)](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-inline-functions.png) [infix functions](\/community\/tutorials\/kotlin-functions) on the other are used to call functions without parentheses or brackets. Doing so, the code looks much more like a natural language. [![kotlin interview questions infix notations](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-infix-notations.png)](https:\/\/scdev.nyc3.cdn.digitaloceanspaces.com\/2018\/04\/kotlin-interview-questions-infix-notations.png)\r\n<\/code><\/pre>\n<ol>\u300c\u61d2\u52a0\u8f7d\uff08lazy\uff09\u300d\u548c\u300c\u5ef6\u8fdf\u52a0\u8f7d\uff08lateinit\uff09\u300d\u4e4b\u95f4\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/ol>\n<pre class=\"post-pre\"><code>Both are used to delay the property initializations in Kotlin `lateinit` is a modifier used with var and is used to set the value to the var at a later point. `lazy` is a method or rather say lambda expression. It's set on a val only. The val would be created at runtime when it's required.\r\n\r\n```\r\nval x: Int by lazy { 10 }\r\nlateinit var y: String\r\n```\r\n<\/code><\/pre>\n<ol>\u5982\u4f55\u521b\u5efa\u5355\u4f8b\u7c7b\uff1f<\/ol>\n<pre class=\"post-pre\"><code>To use the singleton pattern for our class we must use the keyword `object`\r\n\r\n```\r\nobject MySingletonClass\r\n```\r\n\r\nAn `object` cannot have a constructor set. We can use the init block inside it though.\r\n<\/code><\/pre>\n<ol>Kotlin\u6709\u9759\u6001\u5173\u952e\u5b57\u5417\uff1f\u5982\u4f55\u5728Kotlin\u4e2d\u521b\u5efa\u9759\u6001\u65b9\u6cd5\uff1f<\/ol>\n<pre class=\"post-pre\"><code>**NO**. Kotlin doesn't have the static keyword. To create static method in our class we use the `companion object`. Following is the Java code:\r\n\r\n```\r\nclass A {\r\n  public static int returnMe() { return 5; }\r\n}\r\n\r\n```\r\n\r\nThe equivalent Kotlin code would look like this:\r\n\r\n```\r\nclass A {\r\n  companion object {\r\n     fun a() : Int = 5\r\n  }\r\n}\r\n```\r\n\r\nTo invoke this we simply do: `A.a()`.\r\n<\/code><\/pre>\n<ol>\u4ee5\u4e0b\u6570\u7ec4\u7684\u7c7b\u578b\u662f\u4ec0\u4e48\uff1f<\/ol>\n<pre class=\"post-pre\"><code>```\r\nval arr = arrayOf(1, 2, 3);\r\n```\r\n\r\nThe type is Array&lt;Int&gt;.\r\n<\/code><\/pre>\n<p>\u8fd9\u5c31\u662f\u5173\u4e8eKotlin\u9762\u8bd5\u95ee\u9898\u548c\u7b54\u6848\u7684\u5168\u90e8\u5185\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kotlin\u662f\u4e00\u79cd\u6700\u65b0\u7684JVM\u7f16\u7a0b\u8bed\u8a00\uff0c\u7531JetBrains\u63a8\u51fa\u3002\u8c37\u6b4c\u5c06\u5176\u4e0eJava\u4e00\u540c\u8bbe\u5b9a\u4e3aAndroid\u5f00 [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[900,1472,1471,1071,745],"class_list":{"0":"post-483","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"tag-android","8":"tag-kotlin","10":"tag-1071","11":"tag-745"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357 - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u51c6\u5907Kotlin\u9762\u8bd5\uff1f2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff0c\u6db5\u76d6Android\u5f00\u53d1\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u7b54\u3002\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u9ad8\u7ea7\u7279\u6027\uff0c\u52a9\u60a8\u8f7b\u677e\u5e94\u5bf9\u6280\u672f\u9762\u8bd5\uff0c\u6210\u4e3aAndroid\u5f00\u53d1\u4e13\u5bb6\u3002\u67e5\u770b\u5b8c\u6574\u9762\u8bd5\u6307\u5357\uff01\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-\u9762\u8bd5\u95ee\u9898\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357\" \/>\n<meta property=\"og:description\" content=\"\u51c6\u5907Kotlin\u9762\u8bd5\uff1f2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff0c\u6db5\u76d6Android\u5f00\u53d1\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u7b54\u3002\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u9ad8\u7ea7\u7279\u6027\uff0c\u52a9\u60a8\u8f7b\u677e\u5e94\u5bf9\u6280\u672f\u9762\u8bd5\uff0c\u6210\u4e3aAndroid\u5f00\u53d1\u4e13\u5bb6\u3002\u67e5\u770b\u5b8c\u6574\u9762\u8bd5\u6307\u5357\uff01\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-\u9762\u8bd5\u95ee\u9898\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-03T14:30:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-02T04:59:26+00:00\" \/>\n<meta name=\"author\" content=\"\u6587, \u7fd4\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u6587, \u7fd4\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/\",\"name\":\"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-05-03T14:30:28+00:00\",\"dateModified\":\"2025-08-02T04:59:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c\"},\"description\":\"\u51c6\u5907Kotlin\u9762\u8bd5\uff1f2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff0c\u6db5\u76d6Android\u5f00\u53d1\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u7b54\u3002\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u9ad8\u7ea7\u7279\u6027\uff0c\u52a9\u60a8\u8f7b\u677e\u5e94\u5bf9\u6280\u672f\u9762\u8bd5\uff0c\u6210\u4e3aAndroid\u5f00\u53d1\u4e13\u5bb6\u3002\u67e5\u770b\u5b8c\u6574\u9762\u8bd5\u6307\u5357\uff01\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c\",\"name\":\"\u6587, \u7fd4\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g\",\"caption\":\"\u6587, \u7fd4\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/wenxiang\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357 - Blog - Silicon Cloud","description":"\u51c6\u5907Kotlin\u9762\u8bd5\uff1f2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff0c\u6db5\u76d6Android\u5f00\u53d1\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u7b54\u3002\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u9ad8\u7ea7\u7279\u6027\uff0c\u52a9\u60a8\u8f7b\u677e\u5e94\u5bf9\u6280\u672f\u9762\u8bd5\uff0c\u6210\u4e3aAndroid\u5f00\u53d1\u4e13\u5bb6\u3002\u67e5\u770b\u5b8c\u6574\u9762\u8bd5\u6307\u5357\uff01","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-\u9762\u8bd5\u95ee\u9898\/","og_locale":"zh_CN","og_type":"article","og_title":"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357","og_description":"\u51c6\u5907Kotlin\u9762\u8bd5\uff1f2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff0c\u6db5\u76d6Android\u5f00\u53d1\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u7b54\u3002\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u9ad8\u7ea7\u7279\u6027\uff0c\u52a9\u60a8\u8f7b\u677e\u5e94\u5bf9\u6280\u672f\u9762\u8bd5\uff0c\u6210\u4e3aAndroid\u5f00\u53d1\u4e13\u5bb6\u3002\u67e5\u770b\u5b8c\u6574\u9762\u8bd5\u6307\u5357\uff01","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-\u9762\u8bd5\u95ee\u9898\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-05-03T14:30:28+00:00","article_modified_time":"2025-08-02T04:59:26+00:00","author":"\u6587, \u7fd4","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u6587, \u7fd4","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/","name":"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-05-03T14:30:28+00:00","dateModified":"2025-08-02T04:59:26+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c"},"description":"\u51c6\u5907Kotlin\u9762\u8bd5\uff1f2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff0c\u6db5\u76d6Android\u5f00\u53d1\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u7b54\u3002\u4ece\u57fa\u7840\u8bed\u6cd5\u5230\u9ad8\u7ea7\u7279\u6027\uff0c\u52a9\u60a8\u8f7b\u677e\u5e94\u5bf9\u6280\u672f\u9762\u8bd5\uff0c\u6210\u4e3aAndroid\u5f00\u53d1\u4e13\u5bb6\u3002\u67e5\u770b\u5b8c\u6574\u9762\u8bd5\u6307\u5357\uff01","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"2023\u5e74\u6700\u65b0Kotlin\u9762\u8bd5\u9898\u5927\u5168\uff1aAndroid\u5f00\u53d1\u5fc5\u5907\u6307\u5357"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/64d5cc7727fffbff2f9a2a8da1de3e5c","name":"\u6587, \u7fd4","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/920c3d673e0bccacc98e5e6b7149bb3c22edd8d39cb753e5d7d7e471498118a1?s=96&d=mm&r=g","caption":"\u6587, \u7fd4"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/wenxiang\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/kotlin-%e9%9d%a2%e8%af%95%e9%97%ae%e9%a2%98\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=483"}],"version-history":[{"count":4,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":110125,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/483\/revisions\/110125"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}