Kotlin Operators

Kotlin Operators

What are Kotlin Operators?

Kotlin Operators are special symbols or characters that carry out operations on operands (variables and values). For example, + is an operator that performs addition. Kotlin has a set of operators to perform arithmetic, assignment, comparison operators and more. You will learn Kotlin operators in this article.

List Of Kotlin Operators

  1. Arithmetic Operations
  2. Assignments Operations
  3. Comparison operators
  4. Increments and decrements

1. Kotlin Arithmetic Operations

arithmetic Operators Supports arithmetic operations and its comes under the Kotlin Operators

arithmetic Operations like summation, subtraction etc.

below table show some Operations.

Operator SymbolOperator Usage
+Addition Operator
String Concatination
-Substraction Operator
*Multiplication Operator
/Division Operator
%Modulus Operator

Example Of arithmetic Kotlin Operator

+ is also used for connate or merge two string consider below example

output will be like

2.Assignments Operations

Assignments Kotlin Operators are used to assign some values to variable. =

a = 5 ,a = bassign values right to left
variable a has values 5
and variable a is equals to variable b
a += ba = a+b
a -= ba = a-b
a *= ba = a * b
a /= ba = a / b
a %= ba %= b

3.Comparison operators

Comparison operators are always returnĀ  boolean values whether it is true or false

chart is given below

>greater thana > ba is greater then b then true
<less thana < ba is less then b then true
>=greater than or equals toa >= ba is greater or equal to b then true
<=less than or equals toa < = ba is less or equal to b then true
==is equal toa == ba is equals to b then true
!=not equal toa != ba does not equal then true

4.Increments and decrements

Increments and decrement will help you to increase and decrese value of variable by 1

after variable ++ will increase value by 1

same way — will decrese value by 1

a++a = a+1
a--a = a-1

Leave a Comment