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

2025-04-13 12:29:23
推荐回答(2个)
回答(1):

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();
}
}

就这些,如果错误 纯属手误。。希望我的回答能帮助您解决问题!

回答(2):

interface IA
{
public void hello();
}
class a:IA
{
public void override hello(){system.text.console.writeline("hello word!");}
}