JAVA이야기
Java Inner Class
НooпeУ
2010. 8. 10. 14:36
Inner Class의 객체 만드는 법.
public class Nesting {
private int i =1;
private static int si =2;
public class Nested{
int j =3;
private int k =4;
void print(){
// System.out.println(i); //error
System.out.println(si);
System.out.println(j);
}
}
Nesting(){
System.out.println(Nested.k);
}
}
public class NestedClassTest {
public static void main(String[] args) {
Nesting n = new Nesting();
// Nesting.Nested nested = new Nesting.Nested();
Nesting.Nested nested = n.new Nested();
System.out.println(nested.j);
}
}