一个接口包含4个方法,但是我只想实现2个 [英] An interface contain 4 methods , but i want to implement only 2

查看:125
本文介绍了一个接口包含4个方法,但是我只想实现2个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个接口包含4个方法,但是我只想实现2个方法.

我知道我们必须执行.我只是问:有什么办法吗?

An interface contain 4 methods , but i want to implement only 2 methods.

I know upto we must implement. I''m just asking: is there any way?

推荐答案

在实现中创建不需要的方法的方法足迹,而在方法中不执行任何操作.我不认为这是正确的做法,但是会起作用.
Create the method footprint of the unwanted methods in your implementation and do nothing in the method. I don''t think it is the right thing to do but it will work.


显然,我们不能错过这两种方法的实现.这就是接口的含义.
Difinitly we can not miss those two method from implementing. This what for the interfaces are .


在抽象类中实现接口,并创建不想实现抽象的方法.
喜欢
Implement you interface in abstract class.and make methods that you do not want to implement abstract.
like
Interface tt
{
void m1();
void m2();

}
abstract class c1:tt
{
public void m1()
{
.
.
.
}

public abstract void m2();
}


这篇关于一个接口包含4个方法,但是我只想实现2个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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