oracle rewrish не рассказывает о лучшей практике этого ключевого слова , пока мы перегружаем конструкторы. Кто -нибудь может предложить наилучшую практику для этого?public class A {
private int x, y, z, p;
public A() {
this(1,1,1,1);
}
public A(int x, int y, int z, int p) {
this.x = x;
this.y = y;
this.z = z;
this.p = p;
}
}
< /code>
и < /p>
опция 2: Установите каждое поле, а не делегирование < /h1>
public class A {
private int x, y, z, p;
public A() {
this.x = 1;
this.y = 1;
this.z = 1;
this.p = 1;
}
public A(int x, int y, int z, int p) {
this.x = x;
this.y = y;
this.z = z;
this.p = p;
}
}
Подробнее здесь: https://stackoverflow.com/questions/246 ... thin-a-con