抽象方法的目的是什么? [英] What is the purpose of an abstract method?

查看:34
本文介绍了抽象方法的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

abstract public class car 
{   
    abstract void drive();
}

与上面的代码片段一样,Java 中抽象方法的目的究竟是什么?据我所知,根据定义,他们不允许有尸体.

As in the code snippet above, what exactly is the purpose of an abstract method in Java? From what I can gather, by definition, they aren't allowed to have bodies.

推荐答案

当你让事物实现同一个抽象类时,你是说,这些事物在高层次上是相似的,但它们在具体的做法上有所不同事物.抽象方法就是你怎么说,这是扩展这个类的所有事情都必须做的事情,但他们每个人都可以指定他们将如何做."

When you make things implement the same abstract class, you are saying, these things are alike at a high level, but they vary in the particulars of how they do things. An abstract method is how you say, "Here's something that all the things that extend this class have to do, but they each get to specify how exactly they will do it."

这篇关于抽象方法的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆