Abstact use format
Abstract method:
Use the abstract keyword to modify the method, the method becomes an abstract method, the abstract method only contains a method name, but no method body.
Code example
public abstract void run();
Abstract code:
类
package com.kjzz.pojo;
public class Cat extends Animal{
public void run (){
System.out.println("小猫在墙头走");
}
}
测试
package com.kjzz;
import com.kjzz.pojo.Cat;//引入cat
public class Dmoe04 {
public static void main(String[] args) {
Cat c = new Cat();
c.run();
}
}
The output result is: the kitten is walking on the wall
to sum up:
Subclasses that inherit the abstract class must override all the abstract methods of the parent class. Otherwise, the subclass must also be declared as an abstract class. In the end, there must be a subclass that implements the abstract methods of the superclass, otherwise, objects cannot be created from the initial superclass to the final subclass, meaningless.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。