java - 错误:类、接口或枚举预期导入
问题描述
在下面的代码中,我取消了警告,因为我将使用已弃用的 assertEquals 方法。我遇到的问题是,当我运行下面的代码时,出现错误:
MyTests.java:3:错误:类、接口或枚举预期导入 org.junit.*;
@SuppressWarnings("deprecation")
import org.junit.*;
import static org.junit.Assert.*;
public class MyTests {
}
解决方案
注释必须在类上
import org.junit.*;
import static org.junit.Assert.*;
@SuppressWarnings("deprecation")
public class MyTests {
}
但你应该避免使用不推荐使用的方法......
存在同名但签名不同的方法:
assertEquals(double expected, double actual, double delta)
推荐阅读
- r - 如何读取已保存的磁盘帧?
- c - 为什么这 3 行代码会返回地址清理程序错误?
- swift - Swift / Firebase:取消下载图像?
- c - 哪个表达式是使用 sizeof() 始终具有相同内存大小的双指针变量?
- magento2 - 在某些 URL 上涂上 MISS,但在其他 URL 上涂上 HITS
- javascript - 如何使用javascript将innerText更改为php函数
- r - 错误:arrange() 在隐式 mutate() 步骤失败。x 无法为 `..1` 创建临时列
- java - Gremlin:查找给定顶点的所有下游(出)路径
- python - 在Python中根据通道条件替换图像像素颜色
- html - 如何在 CSS 中定义和使用类?