source code to show scope of the static variable
// source code to show scope of the static variable
package variables;
public class StaticVariableExample {
static int i;
// we can access the static variables in static or non-static area
public int m1(){
return i;
}
public static int m2()
{
return i;
}
public static void main(String[] args) {
// static int j; we can declare the static varibles in class level only
}
}
0 comments:
Post a Comment