When is a static nested class (and static members therein) loaded into memory?

前端 未结 2 1736
余生分开走
余生分开走 2021-02-14 01:40

Here, I was trying to implement a singleton class for my Database connectivity using the inner static helper class :

package com.myapp.modellayer;

public class         


        
2条回答
  •  悲&欢浪女
    2021-02-14 02:18

    The oracle doc page says:

    Note: A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class. In effect, a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.

    You it is loaded the same way other classes are loaded.

提交回复
热议问题