阅读220 返回首页    go 阿里云 go 技术社区[云栖]


jdk1.5和jdk1.6对于@override支持的区别

在基类中声明的方法,在继承类中实现的话可以用@Override进行标注。1.5和1.6均正常。但@Override注释在jdk1.5环境下只能用于对继承的类的方法的重写,而不能用于对实现的接口中的方法的实现。

public interface StudentVS
{
 public void saveStudent(Student s);
}


public class StudentVSImpl implements StudentVS
{
 @Override
 public void saveStudent(Student s)
 {
  ..........
 }
}

上述代码在1.5中会报错,而在1.6中不会。所以建议不要加,因为同一项目用不同版本的jdk编译,加上@Override会使用1.5编译的人出错。

 

 

最后更新:2017-04-03 16:49:30

  上一篇:go SVN提示文件被锁住以及Unlocker软件的使用
  下一篇:go J2EE中getParameter与getAttribute以及EL表达式${requestScope}和${param[]}