看看Test1和Test2性能有什么差别吗public interface In
{
void method1();
}
public class InIm implements In
{
public void method1()
{
System.out.println("------------------------");
}
}
public class Test1
{
public static void main(String[] args)
{
In user1 = new InIm();
user1.method1();
}
}
public class Test2
{
public static void main(String[] args)
{
In user1 = new InIm();
user1.method1();
}
}

解决方案 »

  1.   

    Test1写错了,是这个public class Test1
    {
    public static void main(String[] args)
    {
    InIm user1 = new InIm();
    user1.method1();
    }
    }
      

  2.   

    这代码看的头疼 
    能那么多public 吗
    main也两个 是不是代码分开看啊
    interface In
    {
        void method1();
    }
     class InIm implements In
    {
        public void method1()
        {
            System.out.println("------------------------");
        }
    }
    public class Test1
    {
        public static void main(String[] args)
        {
            In user1 = new InIm();
            user1.method1();
        }
    }
    ...........................................
    ...........................................
    public class Test2
    {
        public static void main(String[] args)
        {
            In user1 = new InIm();
            user1.method1();
        }
    }
    两个类是没区别的
      

  3.   


    InIm user1 = new InIm();这句应该会报错吧接口能new么?
      

  4.   


    上面写错了 是In user1 = new In();
      

  5.   

    没有错吧~In是接口,InIm才是实现类。