当前位置: 代码迷 >> J2SE >> 接口变量访问有关问题
  详细解决方案

接口变量访问有关问题

热度:87   发布时间:2016-04-24 14:54:03.0
接口变量访问问题
interface   I{
  int   n=3;
}
class   Test   implements   I{
  int   n=2;
}
两个变量n重复,请问怎么表示这两个n?

------解决方案--------------------
接口的n用I.n可以表示
Test a=new Test();
a.n;//类Test中n的表示
------解决方案--------------------
这个同名就是设计的问题了,重新设计过
  相关解决方案