Can we use local variable before initialization?
class Variable7
{
public static void main(String[] alt)
{
int x;
System.out.println(x);
}
}
/*
Output:- CE[variable x might not have been initialized]
Explanation:- For local variable JVM won't provide any default values. Compulsary we should
perform initialization explicitly before using that variable.
*/
{
public static void main(String[] alt)
{
int x;
System.out.println(x);
}
}
/*
Output:- CE[variable x might not have been initialized]
Explanation:- For local variable JVM won't provide any default values. Compulsary we should
perform initialization explicitly before using that variable.
*/
0 comments: