Just learning about them now and very new to java.
-
stackoverflow.com/questions/4488716/java-default-constructorNPE– NPE2013-02-13 16:12:35 +00:00Commented Feb 13, 2013 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– Jon Skeet2013-02-13 16:12:39 +00:00Commented Feb 13, 2013 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 answerLuiggi Mendoza– Luiggi Mendoza2013-02-13 16:14:16 +00:00Commented Feb 13, 2013 at 16:14
Add a comment
|
2 Answers
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.