" 정적 메서드 외에도 정적 클래스가 있습니다. 나중에 이에 대해 자세히 설명하겠습니다. 지금은 예를 보여 드리겠습니다."

예:
public class StaticClassExample
{
    private static int catCount = 0;

    public static void main(String[] args) throws Exception
    {
        Cat bella = new Cat("Bella");
        Cat tiger = new Cat("Tiger");

        System.out.println("Cat count " + catCount);
    }

     public static class Cat
    {
        private String name;

        public Cat(String name)
         {
            this.name = name;
            StaticClassExample.catCount++;
         }
     }

}
2
과제
Java Syntax,  레벨 6레슨 7
잠금
Code entry
Your attention, please! Now recruiting code entry personnel for CodeGym. So turn up your focus, let your fingers relax, read the code, and then... type it into the appropriate box. Code entry is far from a useless exercise, though it might seem so at first glance: it allows a beginner to get used to and remember syntax (modern IDEs seldom make this possible).

" Cat 개체를 원하는 만큼 만들 수 있습니다. 하지만 정적 변수의 경우에는 그렇지 않습니다. 정적 변수의 복사본은 하나만 존재합니다."

"클래스 선언에서 정적 수정자를 사용하는 주요 목적은 CatStaticClassExample 클래스 사이의 관계를 제어하는 ​​것입니다 . 아이디어는 대략 이렇습니다. Cat 클래스는 StaticClassExample 개체에 연결되어 있지 않으며 인스턴스에 액세스할 수 없습니다(비- static) StaticClassExample 클래스의 변수입니다."

"그러면 수업 안에 수업을 만들 수 있습니까?"

"예. Java는 허용하지만 지금은 너무 많이 생각하지 마십시오. 나중에 몇 가지 사항을 더 설명하면 더 명확해질 것입니다."

"그랬으면 좋겠어, 리시."