永发信息网

怎样写一个接口,实现一个方法,方便调用~~

答案:2  悬赏:0  手机版
解决时间 2021-11-10 19:11
  • 提问者网友:绫月
  • 2021-11-10 14:51
怎样写一个接口,实现一个方法,方便调用~~
最佳答案
  • 五星知识达人网友:轻雾山林
  • 2021-11-10 15:48
java的接口与调用

public interface test_interface
{
public void helloword();
}

public class test_class implements test_interface
{
public void helloword()
{
System.out.println("helloword");
}
}

public class test
{
test_interface inter=new test_class();
inter.helloword();
}

asp.net接口与调用
interface test_interface{
public void helloword();
}

public class test_class : test_interface{
public void test_interface.helloword()
{
console.writeline("helloword");
}

// public void override helloword()
// {
//console.writeline("helloword");
// }

static void Main()
{
test_interface inter = new test_class();
inter.helloword();
}
}

就这些,如果错误 纯属手误。。希望我的回答能帮助您解决问题!
全部回答
  • 1楼网友:青灯有味
  • 2021-11-10 16:22
interface IA
{
public void hello();
}
class a:IA
{
public void override hello(){system.text.console.writeline("hello word!");}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯