Допустим есть класс A с финальными полями
public class A {
protected final int a;
protected final int b;
public A() {
Random random = new Random();
a = random.nextInt();
b = random.nextInt();
}
}
Класс B наследник A
public class B extends A {
}
main:
public class Main {
public static void main(String[] args) {
A a = new A();
B b = new B();
System.out.println(a.a);
System.out.println(a.b);
System.out.println(b.a);
System.out.println(b.b);
}
}
Output:
1290498689
937636620
1338493434
-2021025263
Т.е. поля меняются, не пойму почему??