Hey guys. I’m very new to Kotlin and quite fresh with programming. I’m trying to create a Reverse string program so:
fun main(args: Array) {
var string1 = “Geeks”
var string2 = String()
var l = string1.length
for (i in string1.indices){
string2[i] = string1.get(l-1)
l--
}
print(string2)
}
Of course, the code is wrong so the questions are:
- Can I create an empty string but set the potential number of elements perhaps 5 that are empty and you will fill them out later?
- Can I create just an empty string and then add some elements?
- Can I create a string and then change its elements?
thank you for all your help