Hi ,
I have written a program in which i am trying to understand the static concepts .
I have a doubt , can i access a static variable in a non static method.
because when i am doing that it is executing properly ...
please check the below
import java.io.*;
import java.lang.*;
public class StaticExample{
private static int cal=1;
private static int count = 0;
static void method1(){
System.out.println(" The cal value is " + cal);
}
void method2(){
System.out.println( count);
}
public static void main (
String [] args){
StaticExample ex = new StaticExample();
ex.method1();
ex.method2();
while(count<10){
System.out.println(count++);
}
}
}