Kotlin 类型不匹配:推断类型为字符串,但应为Int
错误:6,17 Kotlin:类型不匹配:推断的类型为字符串,但应为Int 错误:6,19 Kotlin:类型不匹配:推断类型为String,但应为Int您正在将字符串传递给只接受Int的方法。用toInt修复: 您正在将字符串传递给只接受int的方法。用toInt修复: c和d是字符串,为什么您希望它们可以作为int?使用parseInt或string.toInt.c和d都是字符串,为什么希望它们可以作为int使用呢?使用parseInt或string.toInt。Kotlin 类型不匹配:推断类型为字符串,但应为Int,kotlin,Kotlin,错误:6,17 Kotlin:类型不匹配:推断的类型为字符串,但应为Int 错误:6,19 Kotlin:类型不匹配:推断类型为String,但应为Int您正在将字符串传递给只接受Int的方法。用toInt修复: 您正在将字符串传递给只接受int的方法。用toInt修复: c和d是字符串,为什么您希望它们可以作为int?使用parseInt或string.toInt.c和d都是字符串,为什么希望它们可以作为int使用呢?使用parseInt或string.toInt。 fun main(args
fun main(args:Array<String>)
{
println("Enter values of c and d")
var c:String= readLine()!!
var d:String= readLine()!!
try
{
division(c,d)
} catch (e:Exception)
{
println("Exception Occured")
e.printStackTrace()
}
}
fun division(a:Int,b:Int){
println(a/b)
}
division(c.toInt(), d.toInt())