0
Can constructor be public, private, protected
?
4 Antworten
0
class classname{
public classname(){ // these constructor must public
} // same with the class name
// it will executed once during first load
// during classname a = new classname();
}
0
I wouldn't recommend making it private as it needs to be called from outside the class.
0
The only way I can think a private constructor could be used is
Class a{
private a() {
}
Public static void main(String[] args) {
New a();
}
}
0
Thanks