Java examples for Language Basics:Variable
In Java, local variables are not given initial default values.
The compiler ensures that you have assigned a value before you use a local variable.
For example, the following program won't compile:
public class Main { public static void main(String[] args) { int i;/*from ww w . j a va 2s .co m*/ //System.out.println("The value of i is " + i); } }