A quick look at the type system

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);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset