Mike Simmons wrote:So here, you're trying to call getClass() on a reference of type Inner. Which is a private class. The compiler won't let you call any methods on a private class, from outside the top-level class containing the private declaration.
Campbell Ritchie wrote:That is equivalent to calling new outer.Inner().getClass().... where the Inner class is not a true inner class because it is static. You can't access members of such a private nested class from outwith its enclosing class.
Campbell Ritchie wrote:That is equivalent to calling new outer.Inner().getClass().... where the Inner class is not a true inner class because it is static. You can't access members of such a private nested class from outwith its enclosing class.
Stephan van Hulst wrote:
Polymorphism allows you to swap the actual type of an object that a variable refers to without changing the validity of the program.
Carey Brown wrote:No, that is not an override
Campbell Ritchie wrote:I suggest you add a retention to your annotation and see what happens.
Stephan van Hulst wrote:The error message tells you exactly why it can't create an instance of NewInstanceTest1$Dog: It has the private access modifier.
Campbell Ritchie wrote: It also doesn't tell you that you oughtn't to use newInstance() any more.
Campbell Ritchie wrote:
So tried your code and didn't get any exceptions.
Liutauras Vilda wrote:
But that is really what would happen. s[0] trying to access very first element within an array, while s isn't referring to an array of Strings, but rather a singular String.