java 静态内部类总结
发布日期:2021-05-10 00:15:02 浏览次数:15 分类:精选文章

本文共 2801 字,大约阅读时间需要 9 分钟。

������������������������������������������������������������������������������������������������������������������

���������������������������������������������������

  • ���������������������������������������������������������������������������������������������������������/������������������������������������������������������������������

  • ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

  • ������������������������������������ squel &copyforeground declare������������������������������������������������ modifier.��������������������������� squel &copyforeground declare������������������������������

  • ������������������������������������������������������������������������������������������������������������������������������������������������������������

  • ������������������������������������

    1. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
    2. ���������������

      public class Outer {

      static {
      System.out.println("load outer class...");
      }

      static class StaticInner {  
      static {
      System.out.println("load static inner class...");
      }
      static void staticInnerMethod() {
      System.out.println("static inner method...");
      }
      }
      public static void main(String[] args) {
      Outer outer = new Outer();
      System.out.println("===========���������===========");
      Outer.StaticInner.staticInnerMethod();
      }

      }

      ���������������

      load outer class...

      ���������...
      load static inner class...
      static inner method...

      ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

      ������������������������������������������������������������������������������������������������

      public class Singleton {

      private Singleton() {}

      static class SingletonHolder {  
      private static final Singleton instance = new Singleton();
      }
      public static Singleton getInstance() {
      return SingletonHolder.instance;
      }

      }

      ������������������������������������

    3. ������������������������������������������������������������������������������������������

    4. ������������������������������������������������������������������������������������

    5. ���������������������������������������������������������������������������������������������������������������������������

    6. ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������-sensitive������������������������������������

    上一篇:java设计模式文章整理
    下一篇:子类序列化与父类序列化(Serializable)的区别

    发表评论

    最新留言

    不错!
    [***.144.177.141]2025年04月18日 10时12分51秒