Learn Kotlin: Data Types

Variables as boxes — Box Vector by pch.vector on Freepik
Basic data types

1. Basic Data Types

  • Numbers. Kotlin provides a set of built-in data types that represent numbers. For integer/whole numbers, there are four types with different sizes and value ranges. Kotlin provides types Float and Double for floating-point/fractional numbers.
Data types for integer numbers — kotlinlang.org
Data types for fractional numbers — kotlinlang.org
Example of number-typed variables
  • Characters. Represented by the data type Char for single character value.
Example of a Char variable
  • Booleans. Represented by the data type Boolean for one of the two possible values: true and false.
Example of Boolean variables
  • Arrays. Represented by the Array class for group of objects.
Example of Array variables
  • Strings. Represented by the data type String for group of characters (text).
Example of String variable

2. Type inference

Example of type inferenced variables

— Learn Kotlin Series —

  1. Learn Kotlin: Introduction
  2. Learn Kotlin: Hello World!
  3. Learn Kotlin: Variables
  4. Learn Kotlin: Data Types (this article)
  5. Learn Kotlin: Basic Operators
  6. Learn Kotlin: Functions




Android Developer. Currently residing in Jambi, Indonesia. https://romnan.my.id

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Shared (dynamic) Libraries vs. Static Libraries

Assembly “wrapping”: a new technique for anti-disassembly

Using Graph Database when dealing with connected data

Top 10 Links-Monthly Post 2

DevJournal: Developing A Life Sim Game Using Unity and Playmaker #1

Connecting to AWS EC2 Instance Using Putty from Windows

Perform clean install of ويندوز 11 in six different ways

Dissecting the 2019 State of DevOps Report, Part 1: DevOps Practices

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Deddy Romnan Rumapea

Deddy Romnan Rumapea

Android Developer. Currently residing in Jambi, Indonesia. https://romnan.my.id

More from Medium

Java Concepts — All 50 Keywords Examples

Hello World! First Java Program

HackerRank Algorithm

Implement strStr() 🚕