Kotlin Program:

- To take users input & print

Example:

User Input: 12

Output: 12

fun main(args: Array<String>) {
  print("Enter a number : ") 
  val userInput = readLine()!!
  var num:Int =userInput.toInt()
  println("You entered : "+num) 
}

OR

import java.util.Scanner
fun main(args: Array<String>) {
  print("Enter a number : ") 
  val userInput = Scanner(System.`in`)
  var num:Int =userInput.nextInt()
  println("You entered : "+num) 
}

Output:

  Enter a number : 121
  You entered : 121
Program
basic
val userInput = readLine()!!  // !! - used to avoid null values
var num = userInput.toInt() //to take user input & convert it into integer
println("You entered : "+ num) //to print variable

We use readLine() function to read userInput

OR

val userInput = Scanner(System.`in`)
var num = userInput.nextInt() //to take user input & convert it into integer
println("You entered : "+ num) //to print variable

For multiple user input prefer using Scanner() method
But you must import java.util.Scanner in this case

Concept

Coming Soon !

Quick
Tutorial

Quote

Sometimes it’s the smallest decisions that can change your life forever.