gpt4 book ai didi

java - 抽象类和接口(interface)

转载 作者:搜寻专家 更新时间:2023-11-01 03:05:58 26 4
gpt4 key购买 nike

默认情况下,在接口(interface)中,数据成员是静态的和最终的。static是因为不能实例化,但为什么是final呢?

还有一个问题就是连抽象类都不能实例化,那为什么它可以有一个非静态数据成员呢??

最佳答案

and the other question is even the abstract classes can not be instantiated,
then why it can have a non static data member??

因为在抽象类中,您可以定义任意多的功能,然后它的子类可以使用这些功能。

关于java - 抽象类和接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22282870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com