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)
}
Error:(6, 17) Kotlin: Type mismatch: inferred type is String but Int was expected Error:(6, 19) Kotlin: Type mismatch: inferred type is String but Int was expected
c
andd
are strings, why do you expect them to be passable asInt
s? UseparseInt
, orstring.toInt
. – Moira