Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34469
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Why is it called "default constructor"? |
| Date | 2016-06-04 15:31 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <nivab2$14b1$1@gioia.aioe.org> (permalink) |
| References | <default-constructor-20160604183650@ram.dialup.fu-berlin.de> <default-constructor-20160604185253@ram.dialup.fu-berlin.de> |
On 6/4/2016 1:54 PM, Stefan Ram wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
>> So, why is it called »default constructor«?
>
> We can read this in the JLS:
>
> |The declaration:
> |
> |public class Point {
> |int x, y;
> |}
> |
> |is equivalent to the declaration:
> |
> |public class Point {
> |int x, y;
> |public Point() { super(); }
> |}
> |
> |where the default constructor is public because the class
> |Point is public.
>
> So, it says that »public Point() { super(); }« is a »default
> constructor« in the second class declaration.
I am not sure that it does.
I read it as that the implicit default constructor is public because
the class is public.
Not saying that the equivalent is a default constructor but explaining
why the equivalent is public.
Arne
Back to comp.lang.java.programmer | Previous | Next | Find similar | Unroll thread
Re: Why is it called "default constructor"? Arne Vajhøj <arne@vajhoej.dk> - 2016-06-04 15:31 -0400
csiph-web