This question already has an answer here:
- Can we instantiate an abstract class? 15 answers
I have a question about abstract classes.
First of all ... I'm using the google translator, sorry :( I hope you understand.
If abstract classes can not be instantiated, exactly, what is this code:
public class Ppal {
public void start(){
ABS clsAbs = new ABS() {
@Override
public void absMetod() {
}
};
clsAbs.metod();
}
}
ABS:
public abstract class ABS{
public void metod(){}
public abstract void absMetod();
}
ABS clsAbs = new ABS () {...
Is not this an instance? clsAbs can be used and
Abstract classes can not be used, only to create a model of abstraction ...
It could be used as anonymous class but this (ABS clsAbs = new ABS () {...
) not anonymous.
Thank you very much in advance!