In this code, I have a static nested class Dog.
output:
Within main of the outer class, I'm using Class.forName() to get a class literal and then using that class literal to create a Dog.
At line 12, the dog proves it really is a Dog, by barking.
What seems odd is that, the
String I supply as argument to Class.forName() must be "ClassLiteralTest$Dog".
I know that on compilation a .class file with $ separated name is generated, but elsewhere in code, if I want to refer to or create a Dog, as at line 17, I'd use dot syntax. Similarly, Dog.class.getCanonicalName() returns a dot separated name.
So, is the way to understand this, that the fully qualified name of a class, as required by Class.forName(), is the name in the host os file system less '.class', which isn't always the same as the canonical name?