, ONCE . () , .
:
public class A
{
public static int aStaticVal;
public int aVal;
static A() {
aStaticVal = 50;
}
public A() {
aVal = aStaticVal++;
}
}
:
A a1 = new A();
A a2 = new A();
A a3 = new A();
static . ( ).
static , , . , static (, ) static.
" ", . , " " , , . - :
public class A {
public static int a, b;
static A() {
A.ResetStaticVariables();
}
public static void ResetStaticVariables() {
a = b = 0;
}
}