Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.java.programmer > #5022
| Date | 2011-06-06 18:54 +0200 |
|---|---|
| From | Mayeul <mayeul.marguet@free.fr> |
| Newsgroups | comp.lang.java.programmer, comp.lang.java.help |
| Subject | Re: What's the difference between and instance and an object? |
| References | <5d84ac2b-e81b-4c40-b3e3-c7248f1d7298@r35g2000prj.googlegroups.com> <4decfdbc$0$17721$426a74cc@news.free.fr> <1a327de4-8451-4379-a75b-7cc2dab3fb5b@34g2000pru.googlegroups.com> |
| Message-ID | <4ded05bb$0$17813$426a74cc@news.free.fr> (permalink) |
| Organization | Guest of ProXad - France |
Cross-posted to 2 groups.
On 06/06/2011 18:33, Chad 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. This is not a matter of opinion. Here is what the Java Docs have to say: http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.8.9 > So I figured > that when I created instance of MyStack with 'new MyStack()', that the > only instance would be Object since I omitted the MyStack constructor. As you could verify with your simple test, that is incorrect. For starters, for any symbol 'A' denoting a class, 'new A()' will always either: - build an instance of the class 'A' - throw an Exception - refuse to compile Same goes if this call is given parameters. In other words, it cannot possibly build an instance of any other class, neither Object nor anything. -- Mayeul
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
What's the difference between and instance and an object? Chad <cdalten@gmail.com> - 2011-06-06 09:08 -0700
Re: What's the difference between an instance and an object? Chad <cdalten@gmail.com> - 2011-06-06 09:16 -0700
Re: What's the difference between and instance and an object? Patrick <patrick@antispam.invalid> - 2011-06-06 18:18 +0200
Re: What's the difference between and instance and an object? Chad <cdalten@gmail.com> - 2011-06-06 09:33 -0700
Re: What's the difference between and instance and an object? Mayeul <mayeul.marguet@free.fr> - 2011-06-06 18:54 +0200
Re: What's the difference between and instance and an object? Chad <cdalten@gmail.com> - 2011-06-06 10:11 -0700
Re: What's the difference between and instance and an object? Abu Yahya <abu_yahya@invalid.com> - 2011-06-08 21:21 +0530
Re: What's the difference between and instance and an object? Abu Yahya <abu_yahya@invalid.com> - 2011-06-08 21:24 +0530
Re: What's the difference between and instance and an object? Patricia Shanahan <pats@acm.org> - 2011-06-08 09:33 -0700
Re: What's the difference between and instance and an object? Abu Yahya <abu_yahya@invalid.com> - 2011-06-08 22:07 +0530
Re: What's the difference between and instance and an object? Lewis Bloch <lewisbloch@google.com> - 2011-06-10 11:06 -0700
Re: What's the difference between and instance and an object? Abu Yahya <abu_yahya@invalid.com> - 2011-06-11 23:58 +0530
Re: What's the difference between and instance and an object? Lewis Bloch <lewisbloch@google.com> - 2011-06-10 11:05 -0700
csiph-web