Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #558
| From | Lew <noone@lewscanon.com> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: Instantiate an abstract class |
| Date | 2011-04-06 12:49 -0400 |
| Organization | albasani.net |
| Message-ID | <ini5i3$9ci$1@news.albasani.net> (permalink) |
| References | <61c7300d-6011-4639-a5f1-5cd4c58906fa@r4g2000prm.googlegroups.com> <c1u7degm55pf$.dlg@kimmeringer.de> |
On 04/06/2011 12:26 PM, Lothar Kimmeringer wrote: > Rob McDonald wrote: >> When I try it, I get a variety of errors depending on different >> attempts... >> >> AFoo a = new this.getClass(); A very brief study of the Java tutorials will reveal that this is not valid syntax. >> Syntax error on token "this", invalid Name >> >> AFoo a = new (this.getClass()); Likewise. >> AFoo a = new (this).getClass(); And again. >> Syntax error on token "new", ClassType expected after this token As explained in the tutorials: <http://download.oracle.com/javase/tutorial/index.html> > getClass().newInstance(); You left out the object on which to call 'getClass()'. How do you get an instance on which to call the method? What if the constructor is not parameterless? Rob, post a complete class source - not just one-liners. Make a compilable example. It's ok to be compilable with errors for this purpose - we want to analyze the errors. But we cannot reproduce your work or put our answers in context without what's called an "SSCCE" http://sscce.org/ Remember, "compilable" doesn't necessarily have to be "correct" as in "no errors". If the purpose is to discuss the errors, we want an example that has those errors so that we can discuss how to repair them. But do read the tutorials first. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next 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