Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




KOTLIN - BOOLEAN


Boolean represents just two values, i.e. 'true' or 'false'.

Boolean Data Type


A 'Boolean' Data Type can accept only 'true' or 'false'.


Example :



fun main(){
   		
    var x: Boolean = true
    var y: Boolean = false
    println(x) 
    println(y)
}


Output :



 true
 false

So, in the above code, we have created a variable named 'x' of 'Boolean' data type and initialised it with value 'true'.


var x: Boolean = true

java_Collections

And created one more variable called 'y' of 'Boolean' data type and initialised it with value 'false'.


var y: Boolean = false

java_Collections

But if we want to initialise a 'Boolean' type variable with anything other than 'true/false',it would end up with an error.