I am trying to instantiate an abstract Java class from my Groovy code. Given the following abstract Java class (irrelevant processing is excluded from the class):
public abstract class StackOverflow{
public abstract String answerMe();
}
I can easily create an instance in Groovy this way, and the call answerMe()will produce the correct output:
StackOverflow stack = [answerMe : { "Answer" }] as StackOverflow
Now, if I change the class StackOverflowby adding the String parameter to the constructor as follows:
public abstract class StackOverflowStr{
public StackOverflowStr(String s){}
public abstract String answerMe();
}
I really don't know how to instantiate an object, I've tried a lot, but it seems like I can't find the correct syntax, does anyone have any tips?
source
share