I am little confused about initializing final variables.
KM says
"final variable need not be initialized at its declaration, but it must be initialized before it is used"
In code below, I am not using final variable at 2, still I am getting compiler error that variable is uninitialized, why is it so
public class q{
static int x;
final static int y;//2
public static void main(String args[]){
System.out.println(x);
}
}
KM says
"final variable need not be initialized at its declaration, but it must be initialized before it is used"
In code below, I am not using final variable at 2, still I am getting compiler error that variable is uninitialized, why is it so
public class q{
static int x;
final static int y;//2
public static void main(String args[]){
System.out.println(x);
}
}