Can't derive from class with private constructor?

J

Joona I Palaste

(e-mail address removed) scribbled the following:
Just for completeness: protected isn't just package only. A protected
method in a public class can be overridden by subclasses in other
packages; a default-modifier method cannot.

Erm, yes. If you read my post again you'll see I wrote "protected =
subclasses and package only". With this I meant to say that a protected
method or field is visible to all subclasses, no matter what package
they are in, and to all classes in the same package as the original
class, even if they're not its subclasses.

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"'It can be easily shown that' means 'I saw a proof of this once (which I didn't
understand) which I can no longer remember'."
- A maths teacher
 
K

kk_oop

I agree. But fortunately in a usenet, it's very easy to just say
"Well--at least I don't have to work with--or live with--the guy/gal!"
And at least a usenet lets you escape rudeness with the click of a
mouse. Sort of like changing the channel when a political campaign add
comes on. :)

See ya,

Ken
 
I

iamfractal

Joona I Palaste said:
(e-mail address removed) scribbled the following:


Erm, yes. If you read my post again you'll see I wrote "protected =
subclasses and package only". With this I meant to say that a protected
method or field is visible to all subclasses, no matter what package
they are in, and to all classes in the same package as the original
class, even if they're not its subclasses.


Ah.

I see.

I really should learn to read!

..ed

www.EdmundKirwan.com - Home of The Fractal Class Composition
 
G

Grant Wagner

Peter said:
I think that rudeness on Usenet is a sign of an inability to express
oneself and debate in a reasonable manner. It is evidence the lack of
teaching about critical thinking, IMO.

As more people come online and behave in a way that would be unacceptable in
"real life", their online behaviour spills into their "real life". I see
levels of rudeness in public behaviour I did not see 10 years ago.

How people act on the Internet is just another indicator of the decline of
individual responsibility, critical thinking (as you said), and of the
decline of human "civilization" in general. The frightening part is we are
now seeing this same behaviour in "real life".
 
D

Dale King

That's what I have proposed before as well.
I agree with that. I really think they should have used "foreach" and
"in" for the new for loop syntax.

"in" cannot be a keyword as it is in use for things like System.in.
 
D

Dale King

Joona I Palaste said:
Can't you read? Protected is subclasses and package only. What about
classes that are in the same package but don't inherit from the class?


This has been discussed many times and the consensus seems to be that no one
is losing any sleep over it. It would be a non backwards compatible change
to add it and would actually cause more confusion.
 
D

Dale King

Roedy Green said:
In Java 1.0 there used to be private protected. Was that what you
wanted? I have forgotten now what it did.


What it primarily did was not quite work correctly ;-)

I found an interesting article about Java history that sheds some light on
the issue of why the default is package level and that protected also allows
access by package members.

http://www.devx.com/Java/Article/10686/1954?pf=true

In the early, early days there was no such thing as private members.
Everything was always accessible to package members. There would have been
only the default (package level), protected, and public. That is exactly the
same access levels you have with C++ if you consider Java package members to
be the equivalent of friend classes in C++. Private members in C++ are
visible to friend classes so the default is equivalent to C++ private.

Private was only an afterthought. This added an additional level of
protection beyond C++, which probably makes sense because in reality package
members are not quite the same as friend classes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top