Reputation: 501
Getting subject line error while executing simple groovy program
I am new to groovy and java coding, i am getting the subject line error, which I do not think there is a problem with syntax or code
package test.demo
class classExample {
static void main(args) {
// TODO Auto-generated method stub
classExample classVar = new classExample()
int result
result = classVar.sub(5,2)
println "result is: "+result
}
def sub(int var1, int var2){
return (var1-var2)
}
}
The function call to sub should be successful without any error
Upvotes: 0
Views: 1545
Reputation: 20699
You have 2 major problems with your "class".
sub()
method.The whole thing should look like:
package test.demo
class ClassExample {
static void main(args) {
// TODO Auto-generated method stub
ClassExample classVar = new ClassExample()
int result
result = classVar.sub(5,2)
println "result is: "+result
}
def sub(var1,var2){
return (var1-var2)
}
}
Upvotes: 1