PhysicsTeacher.in

High School Physics

static method in java

Java Program – how to use static variable and static method?

This Java Program will show how to use static variables and static methods in Java. Java Program showing use of static variables and static methods class StaticTest{ static int j;int k; void setVal(int p){k=p;j=p;//ok ..non-static method can access a static variable }static void setStatVal(int p){ j=p;//k=p; /*the above statement wont compile, because static can access […]

Scroll to top
error: physicsTeacher.in