| Author |
abstraction
|
manohar reddy
Greenhorn
Joined: Oct 13, 2007
Posts: 12
|
|
|
how to instatiate abstraction
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
An abstraction in Java is probably an interface or abstract class. You can't instantiate these. Both of these will fail: x = new Runnable(); y = new AbstractList(); You can make a concrete class that implements the interface or extends the abstract class. The compiler will require the concrete class to provide all the abstract methods. Here's a concrete class you could instantiate: And there's another tricky way to create a class right in line instead of defining it in its own file: That looks a lot like we instantiated Runnable, an interface, but in fact we defined a tiny class with a run() method. It has no name so it's called anonymous, but it's a perfectly good little class as far as the compiler's concerned. Does that all make sense?
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: abstraction
|
|
|