mercredi 18 juillet 2018

where the class come from?

jdk:1.8_144 os:debian 9

I compile this class:



    public class Singleton {
        private static class SingletonHolder {
            private static final SingleTonInner INSTANCE = new SingleTonInner();
        }
        private static class SingleTonInner{
            public void out(){
                System.out.println("SingleTonInner:out");
            }

        }

        private Singleton() {
        }

        public static final SingleTonInner getInstance() {
            return SingletonHolder.INSTANCE;
        }
    }


But I find 4 .class file on my disk: Singleton$1.class Singleton.class Singleton$SingletonHolder.class Singleton$SingleTonInner.class

Here is a class Singleton$1.class ? what is it?

I use reflection to get constructor but it has no constructor ! It is nothing!

what is this class and where it come form?





Aucun commentaire:

Enregistrer un commentaire