欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

枚举java语言中的修饰符组合

程序员文章站 2023-11-16 17:02:34
package model; /*22:37 2019/7/20*/ /* top class的修饰符组合 abstract final public 2 * 2 * 2 warning: abstract final 冲突 最终,共有2*(2*2-1)=6种修饰符组合用于top class */ ... ......
package model;
/*22:37 2019/7/20*/

/*
top class的修饰符组合
abstract final public
   2    *  2  *  2
warning:
abstract final 冲突
最终,共有2*(2*2-1)=6种修饰符组合用于top class
*/
/*
public abstract class publicabstractclass{}
public final    class publicfinalclass{}
       abstract class abstractclass{}
       final    class finalclass{}
public          class publicclass{}
                class class{}

关于constructor的修饰符组合
abstract  [default] protected public

关于field的修饰符组合
4        *    2      *     2      *     2         *    2
权限                      静态的         瞬态的          同步的
private       缺省         缺省          缺省            缺省
缺省       (not final) (not static) (not transient) (not volatile)
protected
public         final       static       transient       volatile

warning:
volatile final 冲突
最终,共有4*2*2*(2*2-1)=48种修饰符组合用于field

关于method的修饰符组合
4         *   2         *    2      *     2      *        2          *   2
权限                                     静态的             同步的         本地的
private      缺省            缺省         缺省               缺省          缺省
缺省    (not abstract)    (not final) (not static)  (not synchronized) (not native)
protected
public      abstract          final       static        synchronized       native
warning:
abstract 和 private 冲突
abstract 和 final 冲突
abstract 和 synchronized 冲突
abstract 和 static 冲突
abstract 和 native 冲突
所以abstract method 的修饰符组合只有三种:
          abstract
protected abstract
public    abstract
最终,共有4*2*2*2*2+3=67中修饰符组合用于method
*/

/**
 * 这个类列举了所有的用于字段的修饰符组合
 *                  ├构造器的修饰符组合
 *                  └方法的修饰符组合
 * @author zhangxingshuo
 */
abstract class a {
    /*fields*/
    /*transient and volatile*/
    private                transient volatile int privatetransientvolatileintmemberfield;
                           transient volatile int transientvolatileintmemberfield;
    protected              transient volatile int protectedtransientvolatileintmemberfield;
    public                 transient volatile int publictransientvolatileintmemberfield;

//    private   final        transient volatile int privatefinaltransientvolatileintmemberfield=0;
//              final        transient volatile int finaltransientvolatileintmemberfield=0;
//    protected final        transient volatile int protectedfinaltransientvolatileintmemberfield=0;
//    public    final        transient volatile int publicfinaltransientvolatileintmemberfield=0;

    private         static transient volatile int privatestatictransientvolatileintmemberfield;
                    static transient volatile int statictransientvolatileintmemberfield;
    protected       static transient volatile int protectedstatictransientvolatileintmemberfield;
    public          static transient volatile int publicstatictransientvolatileintmemberfield;

//    private   final static transient volatile int privatefinalstatictransientvolatileintmemberfield=0;
//              final static transient volatile int finalstatictransientvolatileintmemberfield=0;
//    protected final static transient volatile int protectedfinalstatictransientvolatileintmemberfield=0;
//    public    final static transient volatile int publicfinalstatictransientvolatileintmemberfield=0;

    /*not transient and volatile*/
    private                            volatile int privatevolatileintmemberfield;
                                       volatile int volatileintmemberfield;
    protected                          volatile int protectedvolatileintmemberfield;
    public                             volatile int publicvolatileintmemberfield;

//    private   final                    volatile int privatefinalvolatileintmemberfield=0;
//              final                    volatile int finalvolatileintmemberfield=0;
//    protected final                    volatile int protectedfinalvolatileintmemberfield=0;
//    public    final                    volatile int publicfinalvolatileintmemberfield=0;

    private         static             volatile int privatestaticvolatileintmemberfield;
                    static             volatile int staticvolatileintmemberfield;
    protected       static             volatile int protectedstaticvolatileintmemberfield;
    public          static             volatile int publicstaticvolatileintmemberfield;

//    private   final static             volatile int privatefinalstaticvolatileintmemberfield=0;
//              final static             volatile int finalstaticvolatileintmemberfield=0;
//    protected final static             volatile int protectedfinalstaticvolatileintmemberfield=0;
//    public    final static             volatile int publicfinalstaticvolatileintmemberfield=0;

    /*transient and not volatile*/
    private                transient            int privatetransientintmemberfield;
                           transient            int transientintmemberfield;
    protected              transient            int protectedtransientintmemberfield;
    public                 transient            int publictransientintmemberfield;

    private   final        transient            int privatefinaltransientintmemberfield=0;
              final        transient            int finaltransientintmemberfield=0;
    protected final        transient            int protectedfinaltransientintmemberfield=0;
    public    final        transient            int publicfinaltransientintmemberfield=0;

    private         static transient            int privatestatictransientintmemberfield;
                    static transient            int statictransientintmemberfield;
    protected       static transient            int protectedstatictransientintmemberfield;
    public          static transient            int publicstatictransientintmemberfield;

    private   final static transient            int privatefinalstatictransientintmemberfield=0;
              final static transient            int finalstatictransientintmemberfield=0;
    protected final static transient            int protectedfinalstatictransientintmemberfield=0;
    public    final static transient            int publicfinalstatictransientintmemberfield=0;


    /*not transient and not volatile*/
    private                int privateintmemberfield;
                           int intmemberfield;
    protected              int protectedintmemberfield;
    public                 int publicintmemberfield;

    private   final        int privatefinalintmemberfield=0;
              final        int finalintmemberfield=0;
    protected final        int protectedfinalintmemberfield=0;
    public    final        int publicfinalintmemberfield=0;

    private         static int privatestaticintmemberfield;
                    static int staticintmemberfield;
    protected       static int protectedstaticintmemberfield;
    public          static int publicstaticintmemberfield;

    private   final static int privatefinalstaticintmemberfield=0;
              final static int finalstaticintmemberfield=0;
    protected final static int protectedfinalstaticintmemberfield=0;
    public    final static int publicfinalstaticintmemberfield=0;

    /*constructors*/
    private   a(                 ){}
              a(int i            ){}
    protected a(int i,int j      ){}
    public    a(int i,int j,int k){}

    /*methods*/
    private            final  static synchronized native void privatefinalstaticsynchronizednativevoidmethod();
                       final  static synchronized native void        finalstaticsynchronizednativevoidmethod();
    protected          final  static synchronized native void protectedfinalstaticsynchronizednativevoidmethod();
    public             final  static synchronized native void publicfinalstaticsynchronizednativevoidmethod();

    private                   static synchronized native void privatestaticsynchronizednativevoidmethod();
                              static synchronized native void        staticsynchronizednativevoidmethod();
    protected                 static synchronized native void protectedstaticsynchronizednativevoidmethod();
    public                    static synchronized native void publicstaticsynchronizednativevoidmethod();

    private            final         synchronized native void privatefinalsynchronizednativevoidmethod();
                       final         synchronized native void        finalsynchronizednativevoidmethod();
    protected          final         synchronized native void protectedfinalsynchronizednativevoidmethod();
    public             final         synchronized native void publicfinalsynchronizednativevoidmethod();

    private                          synchronized native void privatesynchronizednativevoidmethod();
                                     synchronized native void        synchronizednativevoidmethod();
    protected                        synchronized native void protectedsynchronizednativevoidmethod();
    public                           synchronized native void publicsynchronizednativevoidmethod();

    private            final  static              native void privatefinalstaticnativevoidmethod();
                       final  static              native void        finalstaticnativevoidmethod();
    protected          final  static              native void protectedfinalstaticnativevoidmethod();
    public             final  static              native void publicfinalstaticnativevoidmethod();

    private                   static              native void privatestaticnativevoidmethod();
                              static              native void        staticnativevoidmethod();
    protected                 static              native void protectedstaticnativevoidmethod();
    public                    static              native void publicstaticnativevoidmethod();

    private            final                      native void privatefinalnativevoidmethod();
                       final                      native void        finalnativevoidmethod();
    protected          final                      native void protectedfinalnativevoidmethod();
    public             final                      native void publicfinalnativevoidmethod();

    private                                       native void privatenativevoidmethod();
                                                  native void nativevoidmethod();
    protected                                     native void protectednativevoidmethod();
    public                                        native void publicnativevoidmethod();

    private            final  static synchronized        void privatefinalstaticsynchronizedvoidmethod(){};
                       final  static synchronized        void        finalstaticsynchronizedvoidmethod(){};
    protected          final  static synchronized        void protectedfinalstaticsynchronizedvoidmethod(){};
    public             final  static synchronized        void publicfinalstaticsynchronizedvoidmethod(){};

    private                   static synchronized        void privatestaticsynchronizedvoidmethod(){};
                              static synchronized        void        staticsynchronizedvoidmethod(){};
    protected                 static synchronized        void protectedstaticsynchronizedvoidmethod(){};
    public                    static synchronized        void publicstaticsynchronizedvoidmethod(){};

    private            final         synchronized        void privatefinalsynchronizedvoidmethod(){};
                       final         synchronized        void        finalsynchronizedvoidmethod(){};
    protected          final         synchronized        void protectedfinalsynchronizedvoidmethod(){};
    public             final         synchronized        void publicfinalsynchronizedvoidmethod(){};

    private                          synchronized        void privatesynchronizedvoidmethod(){};
                                     synchronized        void        synchronizedvoidmethod(){};
    protected                        synchronized        void protectedsynchronizedvoidmethod(){};
    public                           synchronized        void publicsynchronizedvoidmethod(){};

    private            final  static                     void privatefinalstaticvoidmethod(){};
                       final  static                     void        finalstaticvoidmethod(){};
    protected          final  static                     void protectedfinalstaticvoidmethod(){};
    public             final  static                     void publicfinalstaticvoidmethod(){};

    private                   static                     void privatestaticvoidmethod(){};
                              static                     void        staticvoidmethod(){};
    protected                 static                     void protectedstaticvoidmethod(){};
    public                    static                     void publicstaticvoidmethod(){};

    private            final                             void privatefinalvoidmethod(){};
                       final                             void        finalvoidmethod(){};
    protected          final                             void protectedfinalvoidmethod(){};
    public             final                             void publicfinalvoidmethod(){};

    private                                              void privatevoidmethod(){};
                                                         void        voidmethod(){};
    protected                                            void protectedvoidmethod(){};
    public                                               void publicvoidmethod(){};

//    private   abstract final  static synchronized native void privateabstractfinalstaticsynchronizednativevoidmethod(){};
//              abstract final  static synchronized native void        abstractfinalstaticsynchronizednativevoidmethod(){};
//    protected abstract final  static synchronized native void protectedabstractfinalstaticsynchronizednativevoidmethod(){};
//    public    abstract final  static synchronized native void publicabstractfinalstaticsynchronizednativevoidmethod(){};

//    private   abstract        static synchronized native void privateabstractstaticsynchronizednativevoidmethod();
//              abstract        static synchronized native void        abstractstaticsynchronizednativevoidmethod();
//    protected abstract        static synchronized native void protectedabstractstaticsynchronizednativevoidmethod();
//    public    abstract        static synchronized native void publicabstractstaticsynchronizednativevoidmethod();

//    private   abstract final         synchronized native void privateabstractfinalsynchronizednativevoidmethod(){};
//              abstract final         synchronized native void        abstractfinalsynchronizednativevoidmethod(){};
//    protected abstract final         synchronized native void protectedabstractfinalsynchronizednativevoidmethod(){};
//    public    abstract final         synchronized native void publicabstractfinalsynchronizednativevoidmethod(){};

//    private   abstract               synchronized native void privateabstractsynchronizednativevoidmethod(){};
//              abstract               synchronized native void        abstractsynchronizednativevoidmethod(){};
//    protected abstract               synchronized native void protectedabstractsynchronizednativevoidmethod(){};
//    public    abstract               synchronized native void publicabstractsynchronizednativevoidmethod(){};

//    private   abstract final  static              native void privateabstractfinalstaticnativevoidmethod(){};
//              abstract final  static              native void        abstractfinalstaticnativevoidmethod(){};
//    protected abstract final  static              native void protectedabstractfinalstaticnativevoidmethod(){};
//    public    abstract final  static              native void publicabstractfinalstaticnativevoidmethod(){};

//    private   abstract        static              native void privateabstractstaticnativevoidmethod(){};
//              abstract        static              native void        abstractstaticnativevoidmethod(){};
//    protected abstract        static              native void protectedabstractstaticnativevoidmethod(){};
//    public    abstract        static              native void publicabstractstaticnativevoidmethod(){};

//    private   abstract final                      native void privateabstractfinalnativevoidmethod(){};
//              abstract final                      native void        abstractfinalnativevoidmethod(){};
//    protected abstract final                      native void protectedabstractfinalnativevoidmethod(){};
//    public    abstract final                      native void publicabstractfinalnativevoidmethod(){};

//    private   abstract                            native void privateabstractnativevoidmethod();
//              abstract                            native void        abstractnativevoidmethod();
//    protected abstract                            native void protectedabstractnativevoidmethod();
//    public    abstract                            native void publicabstractnativevoidmethod();

//    private   abstract final  static synchronized        void privateabstractfinalstaticsynchronizedvoidmethod();
//              abstract final  static synchronized        void        abstractfinalstaticsynchronizedvoidmethod();
//    protected abstract final  static synchronized        void protectedabstractfinalstaticsynchronizedvoidmethod();
//    public    abstract final  static synchronized        void publicabstractfinalstaticsynchronizedvoidmethod();

//    private   abstract        static synchronized        void privateabstractstaticsynchronizedvoidmethod();
//              abstract        static synchronized        void        abstractstaticsynchronizedvoidmethod();
//    protected abstract        static synchronized        void protectedabstractstaticsynchronizedvoidmethod();
//    public    abstract        static synchronized        void publicabstractstaticsynchronizedvoidmethod();

//    private   abstract final         synchronized        void privateabstractfinalsynchronizedvoidmethod(){};
//              abstract final         synchronized        void        abstractfinalsynchronizedvoidmethod(){};
//    protected abstract final         synchronized        void protectedabstractfinalsynchronizedvoidmethod(){};
//    public    abstract final         synchronized        void publicabstractfinalsynchronizedvoidmethod(){};

//    private   abstract               synchronized        void privateabstractsynchronizedvoidmethod();
//              abstract               synchronized        void        abstractsynchronizedvoidmethod();
//    protected abstract               synchronized        void protectedabstractsynchronizedvoidmethod();
//    public    abstract               synchronized        void publicabstractsynchronizedvoidmethod();

//    private   abstract final  static                     void privateabstractfinalstaticvoidmethod;
//              abstract final  static                     void        abstractfinalstaticvoidmethod;
//    protected abstract final  static                     void protectedabstractfinalstaticvoidmethod;
//    public    abstract final  static                     void publicabstractfinalstaticvoidmethod;

//    private   abstract        static                     void privateabstractstaticvoidmethod();
//              abstract        static                     void        abstractstaticvoidmethod();
//    protected abstract        static                     void protectedabstractstaticvoidmethod();
//    public    abstract        static                     void publicabstractstaticvoidmethod();

//    private   abstract final                             void privateabstractfinalvoidmethod();
//              abstract final                             void        abstractfinalvoidmethod();
//    protected abstract final                             void protectedabstractfinalvoidmethod();
//    public    abstract final                             void publicabstractfinalvoidmethod();

//    private   abstract                                   void privateabstractvoidmethod();
              abstract                                   void        abstractvoidmethod();
    protected abstract                                   void protectedabstractvoidmethod();
    public    abstract                                   void publicabstractvoidmethod();
}