# Boolean variable true and false en kotlin

**URL:** <https://discuss.kotlinlang.org/t/boolean-variable-true-and-false-en-kotlin/18028>\
**Category:** Support\
**Created:** [June 10, 2020, 11:38am UTC](https://discuss.kotlinlang.org/t/boolean-variable-true-and-false-en-kotlin/18028 "2020-06-10T11:38:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgamarra](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jgamarra](https://discuss.kotlinlang.org/u/jgamarra)\
**Post date:** [June 10, 2020, 11:38am UTC](https://discuss.kotlinlang.org/t/boolean-variable-true-and-false-en-kotlin/18028/1 "2020-06-10T11:38:10Z")

</div>

why if a boolean value is declared true in this exercise, then we call it false Shouldn’t it keep its value true because Is this how we declare it in the variable?

fun main(parametro: Array) {  
val arreglo = IntArray(10)  
for(i in 0…arreglo.size-1) {  
print(“Ingrese elemento:”)  
arreglo[i] = readLine()!!.toInt()  
}  
var ordenado = true  
for(i in 0…arreglo.size-2)  
if (arreglo[i+1] \< arreglo[i])  
ordenado = false  
if (ordenado)  
print(“Los elementos están ordenados de menor a mayor”)  
else  
print(“Los elementos no están ordenados de menor a mayor”)  
}

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [June 10, 2020, 11:58am UTC](https://discuss.kotlinlang.org/t/boolean-variable-true-and-false-en-kotlin/18028/2 "2020-06-10T11:58:12Z")

</div>

Variables can change. Yes, when you first declare the variable you initialize it to `true`. But later you set `ordenado` to `false`. So why should it keep it’s original value. If you don’t want it to change you can declare it as a `val`(value). That means it can only be set once, so the line `ordenado = false` would create an compiler error.
