0
a simple example of static VARIABLE
public class Soldier{ public static int numSol=0; Soldier(){ numSol++; } Soldier(int num){ numSol += num; } } public class MyClass { public static void main(String[ ] args) { Soldier snip1 = new Soldier(); Soldier snip2 = new Soldier(); Soldier comander = new Soldier(2); System.out.println(Soldier.numSol); } }
1 Resposta
0
it will print 4.