在一个类中:
import java.util.*;
public class DemoSet{
     static void fill(Set s){
        s.addAll(Arrays.asList("one tow three four five".split(" ")));
       }
   public static void displays(Set e){
       System.out.println(s.getClass().getName().replaceAll("\\w+\\.",""));
        .....
      }
     .....
     .....
  }
 }
Set 接口的实例s如何调用Object中的getClass(),因为Set(而且里面没有getClass()成员方法)是一个接口,不能继承Object类,为什么能调用Object类的成员方法

解决方案 »

  1.   

    http://blog.csdn.net/jamesliulyc/archive/2009/01/27/3853839.aspx
    我觉得这位大哥的博文可以解释LZ所有的疑问,呵呵。
      

  2.   

    TJLS上的一段话,希望对LZ有帮助:
    If an interface has no direct superinterfaces, then the interface implicitly declares a public 
    abstract member method m with signature s, return type r,and throws clause t corresponding to 
    each public instance method m with signature s, return type r, and throws clause t declared in 
    Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface. It is a compile-time error if the interface explicitly declares such a method m in the case where m is declared to be final in Object.
      

  3.   

    看错了,java中都是默认集成Object的,就算你没有显示的声明继承自Object
      

  4.   

    all class is extends Object class!and Inteface also is class.