Why Kotlin?
来源:互联网 发布:http协议默认端口号 编辑:程序博客网 时间:2024/06/15 01:47
Kotlin是什么:
静态类型编程语言
用于现代多平台应用
100%可与Java™和Android™互操作
#Kotlin是非常简介的编程语言Create a POJO with getters, setters, equals(), hashCode(), toString() and copy() in a single line:data class Customer(val name: String, val email: String, val company: String)Or filter a list using a lambda expression:val positiveNumbers = list.filter { it > 0 }Want a singleton? Create an object:object ThisIsASingleton { val companyName: String = "JetBrains"}
#Kotlin 很安全Get rid of those pesky NullPointerExceptions, you know, The Billion Dollar Mistakevar output: Stringoutput = null // Compilation errorKotlin protects you from mistakenly operating on nullable typesval name: String? = null // Nullable typeprintln(name.length()) // Compilation errorAnd if you check a type is right, the compiler will auto-cast it for youfun calculateTotal(obj: Any) { if (obj is Invoice) obj.calculateTotal()}
#方便使用 兼容JVM上现有libraryUse any existing library on the JVM, as there’s 100% compatibility, including SAM support.import io.reactivex.Flowableimport io.reactivex.schedulers.SchedulersFlowable .fromCallable { Thread.sleep(1000) // imitate expensive computation "Done" } .subscribeOn(Schedulers.io()) .observeOn(Schedulers.single()) .subscribe(::println, Throwable::printStackTrace)Target either the JVM or JavaScript. Write code in Kotlin and decide where you want to deploy toimport kotlin.browser.windowfun onLoad() { window.document.body!!.innerHTML += "<br/>Hello, Kotlin!"}
很好的工具
您接触过Kotlin吗?
您是否考虑尽快转换Kotlin开发呢?
Kotlin使用中遇到什么问题吗?对于Kotlin的发展您怎么看?
阅读全文
0 0
- Why Kotlin?
- Why ?
- why?
- why?
- why
- why?
- why
- Why?
- WHY
- why????
- why
- WHY?
- why
- Why?
- why
- why?
- why
- why
- webLogic获取路径为NULL
- java 从控制台输入数据的案例
- Java 的抽象类
- 树莓派笔记001——树莓派镜像安装
- Java笔试题解(8)
- Why Kotlin?
- Java线程优先级
- AVCodec
- ShellExecute使用管理员身份执行
- Linux访问window下的磁盘分区出现“Error mounting /dev/sda5 at/media”错误的解决方法
- kotlin基础语言知识
- shell中字符串的截取方法、cut基本用法
- JQuery DOM
- 开发者工具:测量页面