I have a class like this:
public abstract class A {
public static final int FIELD;
// some methods
}
and I want to initialize the variable FIELD in a child class. I mean something like this:
public class B extends A {
FIELD = 5;
}
EDIT actually I have multiple classes that extends A and all of them have the variable FIELD but with different values; so the way I found was to refactor the variable FIELD and declare it in super class. is there any other solutions? is it possible to have something like that? thank you for helping.
The point is that child classes of a super class don't have a copy of a static field declared in super class and the super class shares that between them; So there is no way to have a static variable with different values in different child classes. Therefore I will declare the variable FIELD in all of the child classes.
I got all of them from @LenceJava in the comments.
Thank you @LanceJava.