Hi I am having the following code. when i am using instance variables i am getting the output as follows(Default Values)
int value: 0
float value: 0.0
String value: null
Static int value: 0
But if i try declare the local variable and print the default value it is giving an error that the variable should be initialized. Can any one explain me the reason please?
public class DefaultValues {
int a;
float b;
String c;
static int d;
public static void main(String[] args) {
int e; // <----
DefaultValues dv = new DefaultValues();
System.out.println("int value: "+dv.a);
System.out.println("float value: "+dv.b);
System.out.println("String value: "+dv.c);
System.out.println("Static int value: "+d);
System.out.println("local int value: "+e); // <----
}
}