Java – what is the purpose / purpose of abstract classes? Look for real-world examples

Can someone show me an example of an abstract class in Java? Something with real - World Applications (rather than textbook samples) would be preferable

thank you!

Solution

Read this tutorial abstract methods and classes

abstract class GraphicObject {
    int x,y;
    ...
    void moveTo(int newX,int newY) {
        ...
    }
    abstract void draw();
    abstract void resize();
}
class Circle extends GraphicObject {
    void draw() {
        ...
    }
    void resize() {
        ...
    }
}
class Rectangle extends GraphicObject {
    void draw() {
        ...
    }
    void resize() {
        ...
    }
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>