Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm new to Kotlin and I was learning Kotlin in this website. link removed
and I can't change Scanner type to String type. How do I do it?

What I have tried:

import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`) as String
    println("${scanner.length - 1}")
}
Posted
Updated 1-Apr-20 5:06am
v2
Comments
Richard Deeming 1-Apr-20 10:38am    
I've removed the link to the "hyperskill" site from your question, because it doesn't add anything useful, and it makes the question look like spam.
Nelek 1-Apr-20 11:39am    
Joining today and being his very first post... the porbability that exactly that was the reason is pretty high

1 solution

As far as I guess (I may be wrong), you cannot do that. Here you may find typical usage of the Scanner in Kotlin:
Read Data Input using Scanner in Kotlin - Kotlin Programming[^].
 
Share this answer
 
Comments
jinwon2 1-Apr-20 22:46pm    
Thanks! It helped a lot.
CPallini 2-Apr-20 1:23am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900