静态内部类

  1. class SingletonDemo private constructor() {
  2. companion object {
  3. val instance = SingletonHolder.holder
  4. }
  5. private object SingletonHolder {
  6. val holder= SingletonDemo()
  7. }
  8. }