Java/Modifier(제어자)

내부 클래스 static

Bohemian life 2012. 4. 11. 17:05
package com.inner4;//내부 클래스 static 알아보기

public class InnerEx {
	//내부 클래스가 static 변수를 갖고 있으면
	//클래스를 static으로 지정해야 함
	static class StaticInner{
		int iv = 200;
		static int cv = 300;
	}
	public static void main(String[] args){
		InnerEx.StaticInner i = new InnerEx.StaticInner();
		System.out.println(i.iv);
		System.out.println(InnerEx.StaticInner.cv);
	}
}

200

300