+ 2
How to take multiple inputs in kotlin?
Can anyone teach me how can we take multiple inputs from user in kotlin?!
1 Réponse
+ 7
SOWMIYASHREE S ,
there are various possibilities to do this task:
(1) use an input for the number of required inputs and store it in n. then use a loop and take the inputs and count number of inputs. store the inputs in an array. exite counts when count reach the number in n
(2) use input in a loop and store the input values in an array. if put is empty you can exit the loop
(3) use input to take all values needed in one lin. split the input at separator you used (space, comma,...), store result of split in an array.
=> instead of using array to store the inputs, also other data structures can be used.