Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35543 > unrolled thread

Changing accessor on public static class

Started bymike <mikaelpetterson@hotmail.com>
First post2016-09-06 00:53 -0700
Last post2016-09-13 17:39 -0700
Articles 3 on this page of 23 — 7 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Changing accessor on public static class mike <mikaelpetterson@hotmail.com> - 2016-09-06 00:53 -0700
    Re: Changing accessor on public static class Alberto Salvati <zzzato@gmail.com> - 2016-09-06 01:12 -0700
    Re: Changing accessor on public static class Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-06 09:08 -0400
      Re: Changing accessor on public static class Andreas Leitgeb <avl@logic.at> - 2016-09-06 23:00 +0000
        Re: Changing accessor on public static class Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-07 07:48 -0400
    Re: Changing accessor on public static class Eric Douglas <e.d.programmer@gmail.com> - 2016-09-06 07:00 -0700
      Re: Changing accessor on public static class Arne Vajhøj <arne@vajhoej.dk> - 2016-09-06 19:31 -0400
        Re: Changing accessor on public static class Eric Douglas <e.d.programmer@gmail.com> - 2016-09-07 04:47 -0700
          Re: Changing accessor on public static class Arne Vajhøj <arne@vajhoej.dk> - 2016-09-07 18:52 -0400
            Re: Changing accessor on public static class Eric Douglas <e.d.programmer@gmail.com> - 2016-09-08 04:54 -0700
              Re: Changing accessor on public static class Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-08 08:38 -0400
                Re: Changing accessor on public static class Eric Douglas <e.d.programmer@gmail.com> - 2016-09-08 06:35 -0700
                  Re: Changing accessor on public static class Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-09-08 10:09 -0400
                    Re: Changing accessor on public static class Eric Douglas <e.d.programmer@gmail.com> - 2016-09-08 08:18 -0700
                    Re: Changing accessor on public static class Eric Douglas <e.d.programmer@gmail.com> - 2016-09-08 08:37 -0700
                      Re: Changing accessor on public static class Arne Vajhøj <arne@vajhoej.dk> - 2016-09-08 19:34 -0400
                    Re: Changing accessor on public static class Arne Vajhøj <arne@vajhoej.dk> - 2016-09-08 19:32 -0400
              Re: Changing accessor on public static class Arne Vajhøj <arne@vajhoej.dk> - 2016-09-08 19:30 -0400
                Re: Changing accessor on public static class Arne Vajhøj <arne@vajhoej.dk> - 2016-09-08 21:50 -0400
              Re: Changing accessor on public static class Lew <lewbloch@gmail.com> - 2016-09-13 17:44 -0700
      Re: Changing accessor on public static class Lew <lewbloch@gmail.com> - 2016-09-13 17:42 -0700
    Re: Changing accessor on public static class Arne Vajhøj <arne@vajhoej.dk> - 2016-09-06 19:33 -0400
    Re: Changing accessor on public static class Lew <lewbloch@gmail.com> - 2016-09-13 17:39 -0700

Page 2 of 2 — ← Prev page 1 [2]


#35594

FromLew <lewbloch@gmail.com>
Date2016-09-13 17:42 -0700
Message-ID<32a741ec-258d-45b2-aeae-ac696e7167eb@googlegroups.com>
In reply to#35546
Eric Douglas wrote:
> As Eric S said, a top-level class cannot be static, so we're assuming this is an inner class. 

Not possible. By definition, 
"An inner class is a nested class that is not explicitly or implicitly declared static."
https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.1.3

> The only point to a static inner class is if you need an instance of it in a static method.

There is no such thing as a "static inner class".

There is a reason to have static nested classes beyond using them in static methods; if a member type doesn't need access to instance members of the containing type, it should not be an inner class.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#35558

FromArne Vajhøj <arne@vajhoej.dk>
Date2016-09-06 19:33 -0400
Message-ID<nqnjod$13g4$4@gioia.aioe.org>
In reply to#35543
On 9/6/2016 3:53 AM, mike wrote:
> I use this class from another library like this:
>
> app.connect(new Configuration( ipAddress, username));
>
> I tried to make class Configuration not public ( since I did not want
> to expose this name) and it can still be created. Is there any point
> in making it Configuration class not public?

Java got 4 visibility levels. And that is it.

If package visibility works then fine.

If not then public.

Java does not have the friend concept.

Arne

[toc] | [prev] | [next] | [standalone]


#35593

FromLew <lewbloch@gmail.com>
Date2016-09-13 17:39 -0700
Message-ID<77f77557-0f6e-4ed5-b5d0-c06a470a94b7@googlegroups.com>
In reply to#35543
On Tuesday, September 6, 2016 at 12:55:27 AM UTC-7, mike wrote:
> Hi,
> 
> I use this class from another library like this:
> 
> app.connect(new Configuration( ipAddress, username));
> 
> I tried to make class Configuration not public ( since I did not want to expose this name) and it can still be created.
> Is there any point in making it Configuration class not public?
> 
> static class Configuration
. . . 
> public static class Configuration {

These would have to be nested classes. Top-level classes cannot be `static`, since `static` means "belongs to the type".

There is a point to making a class non-public; it makes it accessible only to the more restricted set of client types.

-- 
Lew

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.java.programmer


csiph-web