Answer the question
In order to leave comments, you need to log in
Explain code from Java?
I didn’t understand the explanation of the site, explain why there is an error in line 3, why is the default constructor needed?
Answer the question
In order to leave comments, you need to log in
If no constructor is declared in class A, then by default it contains a constructor without parameters - A(), however, if at least one constructor with parameters is declared, then the constructor A() disappears. But it disappears only when it is not explicitly declared.
Examples
//содержит неявно 1 конструктор A()
class A{
}
//тоже содержит конструктор A() но явно
class A{
A(){
}
}
//cодержит СОДЕРЖИТ ТОЛЬКО 1 конструктор, конструктора A() уже нет
class A{
A(int x){
}
}
//есть оба конструктора
class A{
A(int x){
}
A(){}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question