编程知识 cdmana.com

帮我调试一下 输出一个结果

问题遇到的现象和发生背景

我的代码无法输出结果,它可以运行

用代码块功能插入代码,请勿粘贴截图
import java.util.Set;class changfangxing{    protected int chang;    protected int kuan;public int getChang() {    return chang;}public void setChang(int chang) {    this.chang = chang;}public int getKuan() {    return kuan;}public void setKuan(int kuan) {    this.kuan = kuan;}public int getArea(){    return this.chang*this.kuan;}}class zhengfangxing extends changfangxing{    public void setChang(int width){        this.chang=width;        this.kuan=width;    }    public void setKuan(int width){        this.chang=width;        this.kuan=width;    }   }public class Area {    public static void main(String[]args){        changfangxing chang1=new changfangxing();        chang1.setChang(4);        chang1.setKuan(5);        chang1.getArea();        chang1=new zhengfangxing();        chang1.setChang(4);        chang1.setKuan(5);        chang1.getArea();            }}
运行结果及报错内容

无结果

我想要达到的结果

怎么让它能输出结果呢?

版权声明
本文为[CSDN问答]所创,转载请带上原文链接,感谢
https://ask.csdn.net/questions/7789455

Scroll to Top