Java does not allow top level static classes, just inner static classes.
You can create something like a static class as follows:

1. define the class as final
2. make the constructor private
3. make all the members and methods in the class static

Take a look at the java.lang.Math class for an example.

Mark

On Mon, Sep 21, 2015 at 10:07 PM, weird0 <[email protected]> wrote:

> How can I create a public static class in Android Studio?
>
> I want to create a *public static class Utilities* with static methods so
> that I can use them throughout the application without creating an object.
> I plan to create an AlertDialog and call that in multiple fragments.
>
> But, android Studio throws an error. Rite now, I don't know the exact
> error message because I am sitting here in office and making the post.
>
> Regards
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to