This program instanciates the main class. What's the point of instanciating the main class?
Well.... kinda... actually the program instantiates two objects of class A... I think that one point of confusion is that the class of the type of objects you are creating contains a main() method which creates objects of that class. According to OO terminology, a class is basically a blueprint that objects of that type are created from. Another point of confusion involves the main() method... When you run a
java program, what goes on "behind the scenes" is this... the JVM starts, loads the class you specified (and any others that it needs), and then calls the main() method of the specified class. The main() method is specifically used in java as a point that the JVM can start at.
Does this mean the programm which is defined in main will run two times?
No... the code defined in the main() method will only run once... when the JVM calls it... however, the code in the constructor A()
will run twice.
HTH,
-Nate