|
|
|
1000 Java Tips ebook
|
|
 

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java
programming articles and tips. Please take your copy here.
Take your copy of free "Java Technology Screensaver"!. |
|
Question: Is it new Java feature that my class has no constructor?
|
JavaFAQ Home » Daily Tips

Question: My Java class has no constructor!!!? Is it new Java feature, like generics?
I read that Java creates a
default constructor for every class if I do not do it myself -default one, without
arguments.
I wrote small program where I defined my constructor with two arguments. But in
another place I still need an empty constructor (without arguments).
And my compiler complains that it can not find it!
Answer: Java creates a default constructor
if you have no constructors at all.
If you create even one with arguments a
default constructor will not be created and it is your responsibility to add it
into a program. Printer Friendly Page
Send to a Friend
..
Search here again if you need more info!
|
|
|