- Learn Kotlin Programming(Second Edition)
- Stephen Samuel Stefan Bocutiu
- 205字
- 2021-06-24 14:13:25
Basic types in Kotlin
One of the big changes in Kotlin from Java is that, in Kotlin, everything is an object. If you come from a Java background, then you will already be aware that in Java there are special primitive types that are treated differently from objects. They cannot be used as generic types, do not support method/function calls, and cannot be assigned null. An example is the boolean primitive type.
Java introduced wrapper objects to offer a workaround in which primitive types are wrapped in objects, so that java.lang.Boolean wraps a boolean primitive type in order to smooth over the distinctions. Kotlin removes this necessity entirely from the language by promoting the primitives to full objects.
Whenever possible, the Kotlin compiler will map basic types back to JVM primitives for performance reasons. However, sometimes the values must be boxed, such as when the type is nullable, or when it is used in generics. Boxing is the conversion from a primitive type to a wrapper type, which takes place whenever an object is required but a primitive is presented.
- Java異步編程實戰
- CMDB分步構建指南
- Python數據分析基礎
- NumPy Essentials
- SSM輕量級框架應用實戰
- Hands-On Automation Testing with Java for Beginners
- 編程與類型系統
- Mastering Linux Security and Hardening
- 響應式Web設計:HTML5和CSS3實戰(第2版)
- UX Design for Mobile
- Python Social Media Analytics
- ArcPy and ArcGIS(Second Edition)
- JavaScript設計模式與開發實踐
- Visual Basic 開發從入門到精通
- LiveCode Mobile Development Hotshot