0

Just learning about them now and very new to java.

Jonny
  • 1,001
  • 6
  • 13
  • 35
  • http://stackoverflow.com/questions/4488716/java-default-constructor – NPE Feb 13 '13 at 16:12
  • 7
    @Makoto: That's simply not true. If you provide a *different* constructor, the compiler won't supply a parameterless one. – Jon Skeet Feb 13 '13 at 16:12
  • @Makoto From the link provided by NPE: *if you define at least one constructor, the default constructor is not generated*, and then check the best reference for the answer – Luiggi Mendoza Feb 13 '13 at 16:14

2 Answers2

6

No. If any constructor is defined, there is no default constructor (i assume you mean no-argument constructor) unless you explicitly define it. If no constructors are defined, then the default constructor is implied.

Lucas
  • 14,227
  • 9
  • 74
  • 124
1

If you provide a constructor for your object then it will be used. If you don't call it java won't call the no-argument constructor thus you have to provide it yourself.

I think the official java documentation here provides some examples which are simple to understand.

Adam Arold
  • 29,285
  • 22
  • 112
  • 207