Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在对我实现的接口进行几次 Junit 测试。在设置中,我声明了一个:
整数计数器 = 0;
但在拆解时我做不到:counter = null;
它给了我一条消息“类型不匹配:无法将类型从 null 转换为 int”
如何拆除我的计数器变量?
您不能拆除原语,null 是仅用于对象的值。
将 int 更改为 Integer 或只是省略删除该引用。