-1

I want to declare multiple global variables in Kotlin with names like vehicle1, vehicle2, vehicle3... using a loop.

I think this is how one would do it in C++ ->

for(i=0; i<10; i++){
   int vehicle[1];
}
DawidJ
  • 1,245
  • 12
  • 19

1 Answers1

0

So you want an Array with 10 Strings, each one having different names right? You can do something like this:

val vehicles = emptyArray<String>()
for (i in 0 until 10) vehicles[i] = "vehicle$i"
Ravers
  • 988
  • 2
  • 14
  • 45