简体   繁体   中英

Why in Android documentation Activity classes have static modifier

If we open android documentation we will see that Activity classes have static modifier:

public static class MainActivity extends Activity {...}

I'm used to declaring Activities without static modifier:

public class MainActivity extends Activity {...}

What is the reason behind using static modifier in Activity class declaration?

It's Documentation bug. Sadly, they are not rare. You'd normally only use the static modifier for classes when declaring an inner class that does not need to be linked to the declaring outer class, for example:

public class OuterClass {
    // ...

    // static inner class has no reference to outer class
    public static class InnerClass { 
        // ...
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM