interface DeclareStuff{
public static final int EASY =3;
void doStuff(int t);
}
public class test100 implements DeclareStuff{
public static void main(String[] args) {
int x =5;
new test100().doStuff(++x);
}
void doStuff(int s){
s += EASY+ ++s;
}
}编译不成功 为什么 在test100类里的doStuff方法要加public
解决方案 »
- 大家来讨论技术解决方案!有关文件扫描和数据库的
- liferay ajax应用
- STRUTS2 上传文件类型 限制问题!!!!!!!!!!
- 登陆界面 代码急急急...........
- FCKeditor不显示的问题,请高手指教啊
- >>知道的朋友请进>>Tomcat 报java.io.EOFException,连接MySql问题出错 ?
- weblogic 中远程Debug端口在哪设置
- 急急急!!!在struts(MVC框架)中怎样进行动态图片处理??
- 200分求resin二级域名解决思路
- 求问一个hibernate的配置问题,求大神帮忙看下
- 求教,关于radio跳转的
- jsp页面把table导出为word
官方文档如示:
Java Language Specification, 3rd ed. §9.4 Abstract Method Declarations
http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.4Every method declaration in the body of an interface is implicitly abstract, so its body is always represented by a semicolon, not a block.Every method declaration in the body of an interface is implicitly public.所以接口中的doStuff 的修饰符就是public,它的实现类的方法也就只能是public,否则就破坏了接口的实现规则了。