package com.study.javastudy.study;

public class InnerExam2 {
    static class Cal{
        int value = 0;
        public void plus() {
            value++;
        }
    }

    public static void main(String[] args) {
        // static으로 생성하면 실행할 때 메모리에 따로 영역이 주어지고 생성되기에 InnerExam2에 대한 
        // 객체를 생성할 필요없이 Cal에 대한 객체 생성 후 사용 가능하다
        InnerExam2.Cal cal = new InnerExam2.Cal();
        cal.plus();
        System.out.println(cal.value); // 1
    }
}

+ Recent posts