• +91 9723535972
  • info@interviewmaterial.com

Kotlin Interview Questions and Answers

Question - What is the difference between == operator and === operator in Kotlin?

Answer -

In Kotlin, the == operator is generally used to compare the values stored in variables, and the === operator is used to check if the reference of the variables are equal or not.

In the case of primitive types, the === operator is also used to check for the value and not reference.

Example:

// primitive example  
val int1 = 10   
val int2 = 10  
println(int1 == int2) // true  
println(int1 === int2) // true  
// wrapper example  
val num1 = Integer(10)  
val num2 = Integer(10)  
println(num1 == num2) // true  
println(num1 === num2) //false  

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners