首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Kotlin入门(2)让App开发变得更容易

    上一篇文章介绍了如何搭建Kotlin的开发环境,可是这个开发环境依然基于Android Studio,而在Android Studio上使用Java进行编码,本来就是理所应当的,何必还要专门弄个Kotlin,这个Kotlin相比Java到底有哪些好处呢? 我们可以把Kotlin看作是Java的升级版,它不但完全兼容Java,而且极大精简了代码语法,从而使开发者专注于业务逻辑的编码,无需在繁琐的代码框架之间周旋。当然,若想充分运用Kotlin的优异特性,除了导入Kotlin的核心库,还得导入Kotlin的扩展库与Anko库。具体到编译配置文件,则要进行以下两处修改: 1、打开项目的build.gradle,补充添加anko的版本号声明,以及Kotlin扩展库的路径,完整的编译配置如下所示:

    03

    On the Rise of Kotlin

    It’s rare when a highly structured language with fairly strict syntax sparks emotions of joy and delight. But Kotlin, which is statically typed and compiled like other less friendly languages, delivers a developer experience that thousands of mobile and web programmers are falling in love with. The designers of Kotlin, who have years of experience with developer tooling (IntelliJ and other IDEs), created a language with very specific developer-oriented requirements. They wanted a modern syntax, fast compile times, and advanced concurrency constructs while taking advantage of the robust performance and reliability of the JVM. The result, Kotlin 1.0, was released in February 2016 and its trajectory since then has been remarkable. Google recently announced official support for Kotlin on Android, and many server-side technologies have introduced Kotlin as a feature.

    02

    Kotlin概述与Java的比较

    大家好,又见面了,我是你们的朋友全栈君。Kotlin是JetBrains的一种新的编程语言。它首次出现在2011年,JetBrains推出了名为“科特林”的项目。 Kotlin是开源语言。 基本上像Java一样,C和C ++ – Kotlin也是“静态类型编程语言”。静态类型的编程语言是在使用变量之前不需要定义的那些语言。这意味着静态类型与变量的使用明确声明或初始化有关。 如前所述,Java是静态类型语言的一个例子,类似C和C ++也是静态类型语言。 基本上,静态类型并不意味着我们必须在使用它们之前首先声明所有的变量。变量可以在程序中的任何地方初始化,而我们(开发人员)必须这么做,当有需要时,可以在程序的任何位置使用这些变量。考虑以下示例 – 除了面向对象编程的类和方法之外,Kotlin还支持使用函数进行程序化编程。 像Java,C和C ++一样,Kotlin程序的入口点是一个名为“main”的函数。基本上,它传递一个包含任何命令行参数的数组。考虑以下示例 –

    01
    领券