the time of compilation JVM doesn't provide constructor
when we create any constructor (whether as default or argumented) in a class then , JVM why does not povide constructor开发者_StackOverflow社区 at the time of compilation?
Here's an excerpt from the Java language specification:
If a class contains no constructor declarations, then a default constructor that takes no parameters is automatically provided:
- If the class being declared is the primordial class Object, then the default constructor has an empty body.
- Otherwise, the default constructor takes no parameters and simply invokes the superclass constructor with no arguments.
So in fact the JVM 'provides' the default constructor whenever the class contains no constructor declaration. It is the same as
public MyClass() {}
精彩评论