I am having a list of string as follows.
List l = ["1","2","3"]
And I have a class like as follows.
class person {
String name
}
I want to create a list of person object from List l.
I have tried using groovy list collect but I am not able to do so.
Here is my code.
class testJsonSlurper {
static void main(String[] args) {
List l = ["1","2","3"]
def l2 = l.collect { new person(it) }
println(l2)
}
}
But I getting following error.
Exception in thread "main" groovy.lang.GroovyRuntimeException: Could not find matching constructor for: testJsonSlurper$person(java.lang.String)