> What is the meaning of a protected class?
> I've seen methods being protected when you override
> them, but what is a protected class?
> An inner class is limited in scope to its parents
> class. Isn't this what you are trying to do?
You mean a nested class? No. The enclosing class is not usually its parent, and a nested class can have public visibility.
If you mean an anonyous inner class, public/protected/etc. don't apply because you can never refer to it by name anyway.
I'm still new enough that I'm not sure what the difference is between a nested class and an inner class. Anonymous inner classes are not what I'm referring to. What I do have are nested or inner classes which are extentions of SwingWorker.
These are defined within the parent and appear as myClass$myName.class, whereas anonymous classes appear as myClass$1.class.
> I'm still new enough that I'm not sure what the
> difference is between a nested class and an inner
> class. Anonymous inner classes are not what I'm
> referring to.
Inner classes are a certain kind of nested class--ones that are non-static, I think.
> What I do have are nested or inner
> classes which are extentions of SwingWorker.
> These are defined within the parent and appear as
> myClass$myName.class,
So, inside some class of yours, you define public class MyClass extends SwingWorker? If so, those classes are accessible outside the class that defines them.
> I do NOT use the word public.
> It is defined as class MyClass extends SwingWorker
> and I have no reason to want those classes outside
> the parent.
Ah, then it's package-private and is only visible within the package. And you mean outside the enclosing class, not outside the parent. SwingWorker is the parent, not the class inside which MyClass is defined.
I thought you said earlier that no nested class could be accessed from outside its enclosing class.
jverd,
> For protected, it wouldn't make any sense. Why would you want a class that
> could only be accessed from the same package and by its child class?
Ummmm... isn't that exactly what you get if you omit the public modifier on the class definition? And doesn't that allow you to organise the implementation details within a package as you see fit, without effecting the public interface. And isn't that useful?
Or am I missing something really basic? Or (Great Scott!!!) Am I just plain wrong?
keith.
> jverd,
>
> > For protected, it wouldn't make any sense. Why
> would you want a class that
> > could only be accessed from the same package and by
> its child class?
>
> Ummmm... isn't that exactly what you get if you omit
> the public modifier on the class definition?
Nope. That's package only, not child classes.
> And
> doesn't that allow you to organise the implementation
> details within a package as you see fit, without
> effecting the public interface. And isn't that
> useful?
The package-private as it is (package only, not subclasses) does, yes.