Buscar este blog

jueves, 3 de junio de 2021

Tipos de datos

 //Tipos de datos

private fun tiposDeDatos() {
//String
val myString: String
val myString2: String

myString = "Hola hackermen 2!"
myString2 = "Bienvenidos"
val myString3 = myString + " " + myString2
println(myString3)

//Enteros: Byte (-127 128), Short(-32768 32767), Int(), Long()
val myInt: Int = 1
val myInt2 = 2

println("El resultado de " + myInt + " + " + myInt2 + " es " + (myInt + myInt2))

//decimales float y double
val myfloat = 12.333f
val myDouble = 1.5
println("La resta de los decimales es " + myfloat + " - " + myDouble + " es " + (myfloat - myDouble))

//Boolean (Bool)
val myBool = true
println(myBool)
}

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...