Java中未赋初值变量问题

public class Test3 {


	public int  i1;
	public static int i2;

	public static void main(String[] args) {


		int i3;


		System.out.println(new Test3().i);
		System.out.println(i2);
		System.out.println(i3);
		
	}


}

对于成员变量i1,会赋默认值

对于静态变量i2,会赋默认值

对于临时变量i3,会报错

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
The local variable i3 may not have been initialized

你可能感兴趣的:(java)