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

Writing My Own Backup Software

Given an array of integers nums and an integer k, return the total number of continuous subarrays…

Why you can’t use Heroku free dynos in multiple servers dependent application

Introducing Element’s Treasury Management Initiative

Finding a solution to an Azure web app deployment problem

5 Key Benefits of Routing Software for Your Food Delivery Business

Program a smart device directly, no install needed

Sorting Data Structures in Python

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 101 : What was Multithreading in old-school java like 👀?

Understand the basics of Spring bean life cycle

Coding with Java