大家讲道理2017-04-18 10:52:23
I guess it’s because there is no definition Triangle
和 Rectangle
这两个类.
你可以把光标移动到红色警告先,看是不是弹出 Triangle cannot be resolved to a type
和 Rectangle 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.
大家讲道理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:
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;
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.