I have a superclass Test
with a static variable a
and I've also created a subclass Test1
from which I am able to access superclass static variable.
Is this a valid way to do so? Any explanation is highly appreciated.
public class Test {
public static String a = "";
Test() {
a += "testadd";
}
}
public class Test1 extends Test {
public Test1() {
a += "test1add";
}
public static void main(String args[]){
Test1 test1 = new Test1();
System.out.println(a);
}
}