On Jun 6, 9:33*am, Chad <cdal...@gmail.com> wrote:
> On Jun 6, 9:18*am, Patrick <patr...@antispam.invalid> wrote:
>
> > Le 06/06/2011 18:08, Chad a écrit :
>
> > > How can there be an instance of MyStack when I never made a
> > > constructor for it? That is, I never create a MyStack object.
>
> > You always have a constructor, even if implicit.
> > You created an instance with new MyStack().
>
> Maybe I'm acting like a dweeb about this, but according to the Java
> Docs, when there is no explicit constructor, then the implict
> constructor is Object. I think that is how they say it. So I figured
That is not correct. I know of no place in any of the standard API's
Javadocs that make any statement that could be understood that way. I
don't even know where in the Javadocs you would hope to find such a
statement.
> that when I created instance of MyStack with 'new MyStack()', that the
> only instance would be Object since I omitted the MyStack constructor.
No.
When you omit an explicit constructor, one *for that very type* is
provided by the compiler, so the implicit constructor in your case is
'public MyStack()'.
"All classes have at least one constructor. If a class does not
explicitly declare any, the Java compiler automatically provides a no-
argument constructor, called the default constructor."
<
http://download.oracle.com/javase/tutorial/java/javaOO/
objectcreation.html>
--
Lew