-1

Why java compiler doesn't provide the default constructor when a class contains any parameterized constructor.

yogesh9239
  • 2,910
  • 3
  • 15
  • 11
  • 1
    Because this would mean that every class could be constructed without parameterization, and this is not desirable. Classes might depend upon others objects and primitives in order to work. – Anthony Accioly Apr 05 '14 at 16:25

1 Answers1

2

Because if you explicitly define a constructor, then you're saying something about how a class instance should be instantiated. You want this to be rigidly defined, and a default constructor would work around this.

Java provides a default constructor when none other is defined as a convenience. But if you start defining your own, it has no purpose and is removed.

Kon
  • 10,702
  • 6
  • 41
  • 58