In Kotlin, everything is an object. There are no primitive variables.
The following are the important numeric types:
- Double--64 bit
- Float--32 bit
- Long--64 bit
- Int--32 bit
- Short--16 bit
- Byte--8 bit
Unlike Java, Kotlin does not treat characters as a numeric type. Any numeric operation on a character will result in a compilation error. Consider the following code:
var char = 'c' //Operator '==' cannot be applied to 'Char' and 'Int' //if(char==1) print (char); Null safety
Java programmers are very familiar with java.lang.NullPointerException. Any operations performed on object variable referencing null will throw NullPointerException.
Kotlin's type system aims to eliminate NullPointerException. Normal variables cannot hold null. ...