BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Kotlin Operators – Arithmetic, Assignment, Unary, Logical and More

Last Updated: February 20, 2019 by Chaitanya Singh | Filed Under: Kotlin Tutorial

Operators works on operands and used for calculation. For example, + is an operator and when I use it in a expression like this: a+b, it performs addition on operands a & b. In this guide, we will learn types of operators available in Kotlin and how to use them.

Operators in Kotlin are grouped in following categories:
1. Arithmetic operators
2.

1. Arithmetic Operators

  • + Addition Operator
  • – Subtraction Operator
  • * Multiplication Operator
  • / Division Operator
  • % Modulus Operator

Example of Arithmetic Operators

fun main(args: Array<String>) {

   val num1 = 101.99
   val num2 = 100.50
   var op: Double

   op = num1 + num2
   println("Addition: $op")

   op = num1 - num2
   println("Subtraction: $op")

   op = num1 * num2
   println("Multiplication: $op")

   op = num1 / num2
   println("Division: $op")

   op = num1 % num2
   println("Modulus: $op")
}

Output:

Addition: 202.49
Subtraction: 1.4899999999999949
Multiplication: 10249.994999999999
Division: 1.014825870646766
Modulus: 1.4899999999999949

The Addition operator (+) is also used for the string concatenation. You can read about it here:
String Concatenation in Kotlin

Note: This guide is incomplete. More content is going to be added soon.

❮ PreviousNext ❯

Top Related Articles:

  1. Kotlin Nested and Inner Class with examples
  2. Kotlin Class and Objects – Object Oriented Programming (OOP)
  3. Kotlin Variables and Data Types
  4. Kotlin Keywords, Soft Keywords and Identifiers
  5. Kotlin Tutorial for Beginners | Learn Kotlin

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Kotlin Tutorial

  • Kotlin Tutorial
  • Kotlin in Eclipse IDE
  • Kotlin in IntelliJ
  • First Kotlin Program
  • Kotlin Keywords
  • Kotlin Variables
  • Kotlin Type Casting
  • Kotlin operators
  • Kotlin Input/Output
  • Kotlin Comments

Kotlin String

  • Kotlin String

Kotlin Array

  • Kotlin Array
  • Kotlin Range

Control Flow

  • Kotlin if expression
  • Kotlin when expression
  • Kotlin for loop
  • Kotlin while loop
  • Kotlin do-while loop
  • Kotlin continue
  • Kotlin break

Kotlin Function

  • Kotlin Function
  • Kotlin Recursion
  • Kotlin default and named arguments
  • Lambda functions
  • Higher Order Function

Exception Handling

  • Exception Handling
  • Kotlin try catch
  • Multiple catch blocks
  • Nested try catch
  • Throw keyword
  • Kotlin try expression

Kotlin OOP

  • Class and Objects
  • Kotlin Constructors
  • Kotlin Inheritance
  • Visibility Modifiers
  • Kotlin abstract class
  • Kotlin Interfaces
  • Nested and Inner Class
  • Kotlin Data Class
  • Kotlin Sealed Class

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap