接口可以有静态方法还是java类stati'fy接口方法?

时间:2014-02-18 14:51:30

标签: java static

允许以下内容: -

public interface JustImplementMe
{
   public void ClimbMountain();
}

不允许以下内容: -

public interface StaticMethodInterface
{
   public static void Climb();
}

允许以下内容: -

public class Classic implements JustImplementMe
{
   public void ClimbMountain()
   {

   }
}

不允许以下内容: -

 public class ClassicMusic implements JustImplementMe    
 {
      public static void ClimbMountain()
      {
        // static method cannot hide the instance method in JustImplementMe
      }  
 }  

为什么会这样?感谢。

0 个答案:

没有答案