- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Equality checks in Kotlin (Difference between "==" and "===" Operators)
Kotlin is statistically typed language and it is hundred percent comparable with Java, as it was developed based on JVM. In Kotlin, there are two types of equality checks −
One is denoted by "==" and
The other one is denoted by "===".
As per the official documentation, "==" is used for structural equality, whereas "===" is used for referential equality.
For any expression,
a==b will evaluate to True only when the value of both "a" and "b" are equal.
a===b will evaluate to True only when both "a" and "b" are pointing to the same object.
Example – Equality in Kotlin
In this example, we will demonstrate how these two operators ("==" and "===") work.
fun main(args: Array<String>) { val student1 = "Ram" val student2 = "shyam" val student4 = "Ram" val student3=student1 // prints true as both pointing to the same object println(student1 === student3) // prints false println(student1 === student2) //prints true println(student1 == student4) }
Output
On execution, it will produce the following output −
true false true
- Related Articles
- Equality Operators: == and != in C++
- C++ Relational and Equality Operators
- Perl Equality Operators
- What are equality operators in C++?
- Difference between prefix and postfix operators in C#?
- Difference between "fold" and "reduce" in Kotlin
- Difference between "*" and "Any" in Kotlin generics
- Difference between isNullOrEmpty and isNullOrBlank in Kotlin
- What is the difference between | and || operators in c#?
- What is the difference between >> and >>> operators in Java?
- What is the difference between = and == operators in Python?
- Difference between List and Array types in Kotlin
- What is the difference between = and: = assignment operators?
- What is the difference between the != and operators in Python?
- Difference between Java and Kotlin in Android with Examples

Advertisements