java Eclipse 3.5 无缘无故地生成“方法不适用于参数”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1097603/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse 3.5 is generating a "method not applicable for the arguments" error for no reason at all
提问by Thomas Owens
The error is this:
错误是这样的:
The method add(String, int) in the type DataNode is not applicable for the arguments (String, String)
DataNode 类型中的 add(String, int) 方法不适用于参数 (String, String)
However, in the DataNode class, I have a number of overloaded add()methods, including one that takes a Stringand an intand one that takes two Strings. It appears that Eclipse isn't "seeing" the right add()method.
但是,在 DataNode 类中,我有许多重载add()方法,包括一个采用 aString和 an 的方法int和一个采用两个Strings 的方法。Eclipse 似乎没有“看到”正确的add()方法。
I've tried things like refreshing the project and files and removing the method, saving the file, then adding it back. No matter what I've tried, the error persists.
我尝试过诸如刷新项目和文件并删除该方法、保存文件然后将其添加回来等操作。无论我尝试过什么,错误仍然存在。
Does anyone know the cause and how to correct it?
有谁知道原因以及如何纠正它?
采纳答案by Thomas Owens
Forcing a compile with my Ant build script, some errors were revealed. When I refactored my package names, import statements were added to some files that imported nonexistent files (or at least what should have been nonexistent files, I need to check on that). For some reason, this generated the error that I was seeing. Removing the import statements corrected the problem.
强制使用我的 Ant 构建脚本进行编译,发现了一些错误。当我重构我的包名时,import 语句被添加到一些导入不存在文件的文件中(或者至少应该是不存在的文件,我需要检查一下)。出于某种原因,这产生了我看到的错误。删除导入语句更正了问题。
回答by Markus Lausberg
Try to clean to project direcly Project-Clean
尝试清理以直接投影 Project-Clean
I my case this is working... most of the time.
我的情况这是有效的......大部分时间。

