Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #562
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!news-transit.tcx.org.uk!feeder.news-service.com!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!spln!extra.newsguy.com!newsp.newsguy.com!news3 |
|---|---|
| From | Wojtek <nowhere@a.com> |
| Newsgroups | comp.lang.java.help |
| Subject | Re: Instantiate an abstract class |
| Date | Wed, 06 Apr 2011 12:41:58 -0700 |
| Organization | NewsGuy - Unlimited Usenet $19.95 |
| Lines | 41 |
| Message-ID | <mn.32f97db4f2cae5cc.70216@a.com> (permalink) |
| References | <61c7300d-6011-4639-a5f1-5cd4c58906fa@r4g2000prm.googlegroups.com> |
| NNTP-Posting-Host | pd69406af5e013e31ec1d732b84c4dfd6f76e331ecfae9d48.newsdawg.com |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="iso-8859-15"; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Newsreader | MesNews/1.08.03.00-gb |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.help:562 |
Show key headers only | View raw
Rob McDonald wrote :
> abstract class AFoo {
> void doStuff() {
AFoo a = getNewInstance();
> }
public absract AFoo getNewInstance();
> }
>
> class Bar extends AFoo {
@Overrides
public Bar getNewInstance()
{
return new Bar();
}
> }
>
> class Fred extends AFoo {
@Overrides
public Fred getNewInstance()
{
return new Fred();
}
> }
So "AFoo a" will hold an instance of whatever class extends AFoo, yet
it can be cast into the subclass.
--
Wojtek :-)
Back to comp.lang.java.help | Previous | Next — Previous in thread | Find similar | Unroll thread
Instantiate an abstract class Rob McDonald <rob.a.mcdonald@gmail.com> - 2011-04-05 14:14 -0700
Re: Instantiate an abstract class Patricia Shanahan <pats@acm.org> - 2011-04-05 14:37 -0700
Re: Instantiate an abstract class Rob McDonald <rob.a.mcdonald@gmail.com> - 2011-04-05 14:49 -0700
Re: Instantiate an abstract class Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-04-05 17:48 -0400
Re: Instantiate an abstract class Rob McDonald <rob.a.mcdonald@gmail.com> - 2011-04-05 14:54 -0700
Re: Instantiate an abstract class Patricia Shanahan <pats@acm.org> - 2011-04-05 15:09 -0700
Re: Instantiate an abstract class Lew <noone@lewscanon.com> - 2011-04-06 12:43 -0400
Re: Instantiate an abstract class "John B. Matthews" <nospam@nospam.invalid> - 2011-04-06 22:07 -0400
Re: Instantiate an abstract class Roedy Green <see_website@mindprod.com.invalid> - 2011-04-05 19:02 -0700
Re: Instantiate an abstract class Roedy Green <see_website@mindprod.com.invalid> - 2011-04-05 19:42 -0700
Re: Instantiate an abstract class Lothar Kimmeringer <news200709@kimmeringer.de> - 2011-04-06 18:26 +0200
Re: Instantiate an abstract class Lew <noone@lewscanon.com> - 2011-04-06 12:49 -0400
Re: Instantiate an abstract class Patricia Shanahan <pats@acm.org> - 2011-04-06 10:09 -0700
Re: Instantiate an abstract class Lothar Kimmeringer <news200709@kimmeringer.de> - 2011-04-07 01:01 +0200
Re: Instantiate an abstract class Wojtek <nowhere@a.com> - 2011-04-06 12:41 -0700
csiph-web