- Kotlin Programming By Example
- Iyanu Adelekan
- 199字
- 2021-08-27 20:00:13
Advantages of Kotlin
As previously discussed, Kotlin was designed to be a better Java, and as such, there are a number of advantages to using Kotlin over Java:
- Null safety: One common occurrence in Java programs is the throwing of NullPointerException. Kotlin alleviates this issue by providing a null-safe type system.
- Presence of extension functions: Functions can easily be added to classes defined in program files to extend their functionality in various ways. This can be done with extension functions in Kotlin.
- Singletons: It is easy to implement the singleton pattern in Kotlin programs. The implementation of a singleton in Java takes considerably more effort than when it is done with Kotlin.
- Data classes: When writing programs, it is a common scenario to have to create a class for the sole purpose of holding data in variables. This often leads to the writing of many lines of code for such a mundane task. Data classes in Kotlin make it extremely easy to create such classes that hold data with a single line of code.
- Function types: Unlike Java, Kotlin has function types. This enables functions to accept other functions as parameters and the definition of functions that return functions.
推薦閱讀
- Practical Data Analysis Cookbook
- 程序員面試筆試寶典(第3版)
- INSTANT OpenCV Starter
- R語言經典實例(原書第2版)
- Python Network Programming Cookbook(Second Edition)
- VMware虛擬化技術
- Mastering ROS for Robotics Programming
- Python算法指南:程序員經典算法分析與實現
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- Mastering Python Design Patterns
- Managing Microsoft Hybrid Clouds
- Hadoop 2.X HDFS源碼剖析
- Learning iOS Security
- Visual C++從入門到精通(第2版)
- Java程序設計