This is my code, and I try to call the method in the inner class as shown below (the last line, ic = new oc.Inner()). But I get error.
I am using groovy console, and according to groovy documentation I expect that the Inner class can be called from outer class. I am not sure about the syntax.
class Outer {
private String privateStr = 'some string'
def callInnerMethod() {
new Inner().methodA()
}
class Inner {
def methodA() {
println "${privateStr}."
}
}
}
Outer oc = new Outer()
ic = new oc.Inner()
This is what I get as result:
startup failed:
Script1.groovy: 14: unable to resolve class oc.Inner
@ line 14, column 6.
ic = new oc.Inner()
^
1 error