search

Home  >  Q&A  >  body text

java - 抽象类计算三角形和矩形面积周长,这个红色警告线是哪里报错了???

PHP中文网PHP中文网2802 days ago918

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 10:52:23

    I guess it’s because there is no definition TriangleRectangle这两个类.
    你可以把光标移动到红色警告先,看是不是弹出 Triangle cannot be resolved to a typeRectangle cannot be resolved to a type, if so, that’s why I said it.
    Suggestion: Move the cursor to the error yourself, F2, and look at the pop-up information.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-18 10:52:23

    There is only a red line under the class name because the class is not defined.

    But seeing that you have two files, Triangle.java and Rectangle.java, you should have written these two classes.
    So I guess there are two reasons:

    1. There is a spelling error in your class name. Although the probability of the two class names being spelled incorrectly is very small, this situation cannot be ruled out;

    2. Your Triangle and Rectangle classes are not in the same package as the Test2 class, and you did not import them in Test2.

    In fact, it is best to move the cursor to the error yourself as @taomaokun said and press F2 to see the pop-up information.

    reply
    0
  • Cancelreply