no. pretty much by definition
I've seen people in the past claim they've discovered some secret way to do so:
public abstract class AbstractClass {
public abstract void doStuff();
}
// later that day
AbstractClass ac = new AbstractClass() {
public void doStuff() {
// things
}
}
but that's no longer an abstract class, it's an anonymous class, that is concrete
> anonymous class means that a class is created and
> instantiated in a single line.. but how come abstract
> class allows this instantiation when there should be
> no way to create a object.. ?..
>
> is this a flaw or something ?..
it's not the abstract class that's being instantiated, it's an anonymous concrete subclass that's being instantiated. don't be misled into confusing the reference type (AbstractClass) and the object itself, which is anonymous. consider the following
Object a = new JFrame();
we have a reference to an object, but the reference points to an instance of JFrame. same in my example, it's a reference to AbstractClass, but an instance of a subclass of AbstractClass. you need to understand the difference between references and objects