0

there, I was taught that interface and abstract class has no implementing/method bodies other than method signatures(name, parameters) and return type, so generally, we write:

public void methodName(parameters);

However, I am wondering can we write it like:

public String methodName(parameters);

As it indicates the return type can be in the method when we create interface or abstract class

4

1 回答 1

1

public String methodName(parameters);

绝对应该工作。以下编译良好。

public interface NewInterface {

    public String methodName(String parameter);
}
于 2013-10-17T15:57:45.947 回答