Thread overview
static attribute on class declaration
Mar 13, 2005
John C
Mar 13, 2005
Walter
Mar 14, 2005
Craig Black
March 13, 2005
Purely by accident, I discovered that the compiler doesn't issue an error when the static attribute is used in a class declaration, like so:

    public static class MyClass {
    }

It doesn't appear to be documented, so does it have a purpose? I initially thought it might be a shorthand for final and abstract (classes that can neither be instantiated nor derived from), but no.

Anyway, just curious.

John.


March 13, 2005
"John C" <johnch_atms@hotmail.com> wrote in message news:d102ra$skm$1@digitaldaemon.com...
> Purely by accident, I discovered that the compiler doesn't issue an error when the static attribute is used in a class declaration, like so:
>
>     public static class MyClass {
>     }
>
> It doesn't appear to be documented, so does it have a purpose? I initially thought it might be a shorthand for final and abstract (classes that can neither be instantiated nor derived from), but no.

Because of the way attributes are parsed, ones that make no sense are just ignored. This is for things like:

    static:

    // everything that follows is static


March 14, 2005
> Because of the way attributes are parsed, ones that make no sense are just ignored. This is for things like:
>
>    static:
>
>    // everything that follows is static

Cool.

-Craig