Sunday, May 28, 2017

The integer literal does not conform to the expected type String

Hi Guys ,

There are multiple reasons for getting this error .

1. If you have a class for which you are trying to create an object and you have missed to specify any of the class variables while creating the object, you might face the exception like :
The boolean literal does not conform to the expected type String .

Take a look at the program below :

class Student(
    val name: String,
    var age: Int
)

fun main(args: Array<String>) {
    val student= Student(1)
    println(student.name)
    println(student.age)
}


If you try to run the above program you might face an error like .
Click here to run this test.



No comments:

Post a Comment

ec2-user@ec2 Permission denied