Kotlin 概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Kotlin 是一种静态类型的开源编程语言,它既支持面向对象的编程,又支持函数式编程。Kotlin 提供的语法和概念与其他语言(包括 C#、Java 和 Scala 等等)类似。Kotlin 的目标并不是独树一帜,而是从几十年的语言发展中汲取灵感。它以变体的形式存在,这些变体以 JVM (Kotlin/JVM)、JavaScript (Kotlin/JS) 和原生代码 (Kotlin/Native) 为目标。
Kotlin 由 Kotlin 基金会管理,这是一个由 JetBrains 和 Google 联手创办的组织,负责语言的推动和持续发展。Google 正式支持 Kotlin 用于 Android 开发,这意味着,Android 文档和工具的设计考虑到了 Kotlin。
某些 Android API(如 Android KTX)是 Kotlin 特有的,但大多数是用 Java 编写的,可以通过 Java 或 Kotlin 调用。Kotlin 与 Java 的互操作性是其发展的核心。这意味着,您可以通过 Kotlin 调用 Java 代码,从而利用所有现有的 Java 库,反之亦然。Kotlin 颇受欢迎,因而能够在 Android 平台上带来更好的开发体验,但开发 Android 框架时,会继续同时考虑到 Kotlin 和 Java。
Kotlin 与 Java 的互操作性意味着您不必一次性采用 Kotlin。您可以让项目同时包含 Kotlin 和 Java 代码。如需详细了解如何将 Kotlin 添加到现有应用,请参阅将 Kotlin 添加到现有应用。如果您是大型团队的一员,那么您的组织和代码库的大小可能需要特别关注。如需了解提示和其他信息,请参阅为大型团队采用 Kotlin。
如果您想从头开始学习 Kotlin,我们提供了 30 分钟的速成课程,可帮助您轻松上手使用 Kotlin。您可以在 https://kotlinlang.org 上找到 Kotlin 官方文档。如需了解推荐的图书,请参阅图书。
如需查看特定于 Android 的 Kotlin 示例,请参阅 Android 平台中常见的 Kotlin 模式。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Kotlin overview\n\nKotlin is an open-source, statically-typed programming language that supports\nboth object-oriented and functional programming. Kotlin provides similar\nsyntax and concepts from other languages, including C#, Java, and Scala, among\nmany others. Kotlin does not aim to be unique---instead, it draws\ninspiration from decades of language development. It exists in variants that\ntarget the JVM (Kotlin/JVM), JavaScript (Kotlin/JS), and native code\n(Kotlin/Native). \n\nKotlin is managed by the\n[Kotlin Foundation](https://kotlinlang.org/foundation/kotlin-foundation.html),\na group created by [JetBrains](https://www.jetbrains.com/) and\nGoogle, that is tasked with advancing and continuing development of the language.\nKotlin is officially supported by Google for Android development, meaning that\nAndroid documentation and tooling is designed with Kotlin in mind.\n\nCertain Android APIs, like [Android KTX](/kotlin/ktx), are Kotlin-specific, but\nmost are written in Java and can be called from either Java or Kotlin. Kotlin's\ninteroperability with Java is core to its growth. It means that you can call\ninto Java code from Kotlin and vice-versa, leveraging all of your existing Java\nlibraries. Kotlin's popularity results in a nicer development experience on\nAndroid, but development of the Android framework continues with both Kotlin and\nJava in mind.\n\nKotlin's interoperability with Java means that you don't have to adopt Kotlin\nall at once. You can have projects with both Kotlin and Java code. For more\ninformation on adding Kotlin to an existing app, see\n[Add Kotlin to an existing app](/kotlin/add-kotlin). If you are a part of a\nlarger team, the size of your organization and codebase may necessitate special\nfocus. For tips and other information, see\n[Adopt Kotlin for large teams](/kotlin/adopt-for-large-teams).\n\nIf you're looking to start from scratch with Kotlin, we offer a\n[30-minute crash course](/kotlin/learn) to help you get started with Kotlin. You\ncan find the official Kotlin documentation at\n[https://kotlinlang.org](https://kotlinlang.org/). For recommended books, see\n[Books](https://kotlinlang.org/docs/books.html).\n\nFor Android-specific Kotlin examples, see\n[Common Kotlin Patterns in Android](/kotlin/common-patterns)."]]