create object for abstract class?

Is any way to create object for an abstract class?
[57 byte] By [sunhema] at [2007-11-27 2:35:25]
# 1
Do you understand "abstract class" anyway? Likely not. I recommend you to follow or read some basic Java courses. For example: http://java.sun.com/docs/books/tutorial/java/IandI/index.html
BalusCa at 2007-7-12 2:53:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

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

georgemca at 2007-7-12 2:53:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
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 ?..
cracjana at 2007-7-12 2:53:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

> 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

georgemca at 2007-7-12 2:53:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...