example to show the scope of the instance variables
// sample example to show the scope of the instance variables
package variables;
public class InstanceVariablesExample {
int i=10;
// we can access the instance variables with in the instance methods , instance blocks only
public int m1(){
return i;
}
public static int m2()
{
return i; // it is the static method instance variable not allowed here
}
public static void main(String[] args) {
}
}
0 comments:
Post a Comment