Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34842 > unrolled thread
| Started by | galt_57@hotmail.com |
|---|---|
| First post | 2016-07-10 08:24 -0700 |
| Last post | 2016-07-10 23:58 -0700 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
Static inner class galt_57@hotmail.com - 2016-07-10 08:24 -0700
Re: Static inner class Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-10 13:30 -0400
Re: Static inner class Lew <lewbloch@gmail.com> - 2016-07-11 10:22 -0700
Re: Static inner class Roedy Green <inquiry@mindprod.com> - 2016-07-10 23:58 -0700
| From | galt_57@hotmail.com |
|---|---|
| Date | 2016-07-10 08:24 -0700 |
| Subject | Static inner class |
| Message-ID | <5e1e4b01-002a-4652-8a0a-45a850a4d0b0@googlegroups.com> |
What is the purpose or special characteristic of a static inner class? Thanks.
[toc] | [next] | [standalone]
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Date | 2016-07-10 13:30 -0400 |
| Message-ID | <nlu0oj$p9$1@dont-email.me> |
| In reply to | #34842 |
On 7/10/2016 11:24 AM, galt_57@hotmail.com wrote:
> What is the purpose or special characteristic of a static inner class? Thanks.
Technically speaking, there is no such thing as a "static inner
class." By definition, an "inner class" is non-static.
There's a good introduction to nested classes (both kinds) at
http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html
Have you read it? If not, do so: I think you'll find it helpful.
If you are still unsure after reading it, post again -- with more
detail about what confuses you.
--
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2016-07-11 10:22 -0700 |
| Message-ID | <d6563b41-42a7-4859-8e6c-4859d6d9fbf9@googlegroups.com> |
| In reply to | #34844 |
Eric Sosman wrote: > galt_57 wrote: > > What is the purpose or special characteristic of a static inner class? Thanks. > > Technically speaking, there is no such thing as a "static inner > class." By definition, an "inner class" is non-static. > > There's a good introduction to nested classes (both kinds) at > > http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html > > Have you read it? If not, do so: I think you'll find it helpful. > If you are still unsure after reading it, post again -- with more > detail about what confuses you. To elucidate a bit further: A static, or non-inner nested class or interface is a member type of a containing, or outer type https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.5 Being 'static', it belongs to the outer type as a whole, not to any specific instance of the outer type, the same way as for a member variable or method. Nested types have access to members of the outer type. If 'static', of course, they can only access 'static' members because you need an instance to reference instance members. You nest a type to make sure it is only used by or in very close association with the containing type. An example from the standard API is https://docs.oracle.com/javase/8/docs/api/java/util/Map.Entry.html It really doesn't make sense to use a 'Map.Entry<K,V>' except in the context of a 'Map<K,V>'. -- Lew
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <inquiry@mindprod.com> |
|---|---|
| Date | 2016-07-10 23:58 -0700 |
| Message-ID | <9sg6obh97klhn3frkm4sba1a8a2nrkvkp8@4ax.com> |
| In reply to | #34842 |
On Sun, 10 Jul 2016 08:24:03 -0700 (PDT), galt_57@hotmail.com wrote: >What is the purpose or special characteristic of a static inner class? Thanks. see http://mindprod.com/jgloss/nestedclasses.html
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web