Java 类的继承中出现已定义类型错误

Java 类的继承中出现已定义类型错误
运行结果及报错内容
package chapter7;
class Shape { }                            
class Square extends Shape{}
class Circular extends  Shape{} 

public class Demo6 {
    public static void draw(Shape s) {
        if (s instanceof Square) {
            System.out.println("zhengfangxing");
        }else if(s instanceof Circular) {
            System.out.println("yuanxing");
        }else {
            System.out.println("shape");
        }
    }
    public static void main(String[] args) {
        draw(new Shape());
        draw(new Square());
        draw(new Circular());
    }
}

报错内容
class Square extends Shape{}
class Circular extends  Shape{}

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/793094000666161.png "#left")
我想要达到的结果

img

您好,我用eclipse跑你的代码,能正常输出:

img


你可以关闭编辑窗口后再打开试试,
如果还有错误,看错误说是静态方法调用错误,建议把draw方法的static去掉,在main中调用时,new Demo6().draw();用这种方式试试,希望可以解决你的问题。