- 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.
- Objective-C Memory Management Essentials
- 單片機C語言程序設計實訓100例:基于STC8051+Proteus仿真與實戰
- 認識編程:以Python語言講透編程的本質
- MATLAB應用與實驗教程
- Python:Master the Art of Design Patterns
- Learning Python Design Patterns
- Python圖形化編程(微課版)
- 零基礎學C語言第2版
- Processing創意編程指南
- Learning Node.js for .NET Developers
- CRYENGINE Game Development Blueprints
- Hadoop 2.X HDFS源碼剖析
- Learning Ionic
- C指針原理揭秘:基于底層實現機制
- Xamarin Cross-Platform Development Cookbook