Java static modifier
- "static" is a modifier applicable for methods & variables but not for classes.(not for top-level classes but for inner classes we can apply)
- We can't declare top level classes with static modifier but we can declare inner classes as "static".
- in the case of instance variables for every object a separate copy will be created but in the case of static a single copy will be created at the class level and this will be shared by every object of that class. example:-class Test{static int x=10;int y=20;public static void main(String [ ]args){Test t1 =new Test( );t1.x = 888;t1.y = 999;Test t2 =new Test( );System.out.println(t2.x +".........."+t2.y);}}output is;