package zh.codegym.task.task13.task1316;
/*
错误的行
*/
public class Solution {
public static void main(String[] args) throws Exception {
System.out.println(SimpleObject.NAME);
System.out.println(Button.NAME);
}
interface SimpleObject {
String NAME = "SimpleObject";
void onPress();
}
interface Button extends SimpleObject {
final String NAME = "提交";
public void onPress();
protected void onPress();
void onPress();
private void onPress();
protected String onPress(Object o);
String onPress(Object o);
private String onPress(Object o);
}
}
为什么保留34行而不是24行?
已解决
评论 (4)
- 受欢迎
- 新
- 旧
你必须先登录才能发表评论
Thomas
30 三月, 07:13
What exactly is the question?
0
zhoubin978
30 三月, 07:36
我认为24行应该是正确的,但事实上34行才是。我不知道我错过了哪里?
0
Thomas
30 三月, 07:55
as said in the other thread, all methods defined in an interface are implicitly public.
-> line 24 is the same as
void onPress();
and that's already defined in the base interface
On the other hand
String onPress(Object o);
hasn't been defined in the base interface, means nothing prevents you from defining it in the Button interface. The Syntax is OK -> perfect
Once you get used to that it'll be just normal.
0
zhoubin978
30 三月, 07:58
right, i think i should get used of it.
0