I'm new to Java. I'm trying to solve the question below, which requires me to answer the [???] part.
I have already read inner class, and reflection on multiple sources but still cannot solve it.
class A{
static class B {}
static class C {
B b;
C(B b) { this.b=b; }
int foo() { return 42; }
}
}
public class Exercise{
public static void main(String [] arg){
assert ([???].foo()==42);
}
}
I tried
assert (A.C.foo()==42);
and got error: non-static method foo() cannot be referenced from a static context
I cannot change any other part of the code, but the [???] part. This is how the challenge is designed. This challenge is classified as easy so maybe I'm missing something critical ?