On Tuesday, September 22, 2015 at 8:14:00 AM UTC-7, Mark Phillips wrote:
>
> Java does not allow top level static classes, just inner static classes. 
>

There is no such thing as an "inner static class" in Java. Nested classes 
are either inner or static, never both.
<https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.1.3>
"An *inner class* is a nested class that is not explicitly or implicitly 
declared static."
 

> 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.
>
> On Mon, Sep 21, 2015 at 10:07 PM, weird0 <[email protected] <javascript:>
> > wrote:
>
>> How can I create a public static class in Android Studio?
>>
>
Make it a nested class contained in another class.

'static' doesn't make any sense at all for a top-level class.
 

>
>> 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. 
>>
>
You cannot use 'static' there. Just make it a regular class with a private 
constructor.
 

>
>> 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 
>>
>
What rite are you performing?
 
You need to learn the basics of Java syntax. Oracle has some really good 
tutorials on their site.
 

-- 
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