val line = scanner.nextLine()
read a whole line, i.e. "Hello, Kotlin"
val num = scanner.nextInt()
read a number, i.e. 123
val string = scanner.next()
read a string, i.e. "Hello"
**val scanner = Scanner(System.
in)**
val s1 = scanner.nextLine()
val s2 = scanner.nextLine()
val num = scanner.nextInt()
- There are three most common numeric types:
Int
,**Long**
, andDouble
. - Type conversion by invoking a special function, for example,
toInt()
,toLong()
,toDouble()
, and so on. - val n = 8 // Int
- val d = 10.09 // Double
- val c = '@' // Char
- val b = true // Boolean
- val s2 = d.toString() // "10.09"
- val s3 = c.toString() // "@"
- val s4 = b.toString() // "true"