如果我有一个具有形式变量的抽象类
protected static final int blah;
protected static final int blah2;
我有两个扩展这个抽象类的类,并将这些变量设置为它们构造函数中常量文件中的“静态最终 int”值,它们会破坏彼此的值吗?如果我想做这样的事情,你会建议我做什么?
所以,例如,如果我有
impl1 类:
public impl1 extends absClass{
public impl1(){
this.blah = CONSTANTS.impl1_blah;
this.blah2 = CONSTANTS.impl1_blah2;
}
}
impl2 类:
public impl2 extends absClass{
public impl2(){
this.blah = CONSTANTS.impl2_blah;
this.blah2 = CONSTANTS.impl2_blah2;
}
}
这是允许的吗?如果没有,我该怎么办?