Buscar este blog

jueves, 3 de junio de 2021

Bucles

 //Bucles

fun bucle(){

val myArray:List<String> = listOf("Hola" , "Bienvenido al tutorial", "Suscribete")
val myMap:MutableMap<String,Int> = mutableMapOf("Brais" to 1, "Pedro" to 2, "Sara" to 5)
//Bucles: for y while

//Imprimiendo el contenido del array con el bucle for
for (myString: String in myArray){
println(myString)
}

//Imprimiendo el contenido del mapa con el bucle for
for (myElement:MutableMap.MutableEntry<String, Int> in myMap){
println(myElement.value)
}

for (x in 0..30 step 3){
println(x)
}

for (x in 20 downTo 0 step 2){
println(x)
}

//Buble while
var x = 0
while (x < 10){
println(x)
x++
}
}

Cuando no reconoce los elementos el MainActivity

  If you are using Android Studio 4.1, you need to add the description to build.gradle (Module: .app). Si está utilizando Android Studio 4.1...