Static method in Java is a method which belongs to the class and not to the object. A static method can access only static data. It is a method which belongs to the class and not to the object(instance).
//Static Variables and Static Methods class staticTest { static int a=10; int b=20; void show() { System.out.println("A : "+a+" B : "+b); } static void display() { System.out.println("A : "+a); } } public class stat_vari_methods { public static void main(String args[]) { staticTest o1=new staticTest(); o1.show(); staticTest o2=new staticTest(); o2.b=100; staticTest.a=200; o2.show(); o1.show(); } }
A : 10 B : 20 A : 200 B : 100 A : 200 B : 20To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions