Code: Select all
class Outsider{
public static class Insider{ // Line # 1
}
}
class TestClass{
public static void main(String[] args){
Outsider os = new Outsider();
Outsider.Insider in = Outsider.new Insider(); // Line # 2
}
}
The last answer option available to Problem # 53 says "You cannot refer to Insider class directly. Outsider.new Insider() is wrong as well because Insider is not static;"
I wanted to test that so I made changes and came up with Line # 2 above.
In order to test the right-hand side of the statement on Line # 2, I've modified the original code in the question by adding
"Outsider."
to
"Insider in = Outsider.new Insider()"
I ran it and Insider not being static did not seem to be the problem.
I instead encountered
"error: cannot find symbol
Outsider.Insider in = Outsider.new Insider();
symbol: variable Outsider
location: class TestClass
1 error"
with or without "static" being added on Line # 1.
The symbol the error message refers to is "Outsider" on the right-hand side.
Am I missing something here? Thanks.
Schmichael
PS
Both classes were in the same file when being run.