Java 错误 - 实际和形式参数列表的长度不同 [英] Java Error - Actual and formal argument lists differ in length
问题描述
我正在尝试调用一个方法,但它给出了这个错误:
I am trying to call a method, but it is giving this error:
java:112:错误:必填:字符串、字符串
找到:字符串
原因:实际和形式参数列表的长度不同
reason: actual and formal arguments lists differ in length
这是我要调用的方法:
public void setShippingDest(String inCustName, String inDestn) {
// ...
}
这就是我试图称呼它的方式:
Here is how I'm trying to call it:
shipOrder.setShippingDest("Broome");
推荐答案
其实很简单.下面是 setShippingDest
的声明:
Well it's quite simple. Here's the declaration of setShippingDest
:
public void setShippingDest(String inCustName, String inDestn)
这就是你试图称呼它的方式:
And here's how you're trying to call it:
shipOrder.setShippingDest("Broome");
您提供了一个参数,但有两个参数?你希望它如何运作?您要么需要提供另一个参数,要么删除一个参数.
You've provided one argument, but there are two parameters? How do you expect that to work? You either need to provide another argument, or remove one parameter.
(我还强烈建议您从所有参数中删除 in
前缀,并查看真正的单元测试框架,例如 JUnit,而不是编写庞大的 main
方法.)
(I'd also strongly advise that you remove the in
prefix from all of your parameters, and look into a real unit testing framework such as JUnit, rather than writing an enormous main
method.)
这篇关于Java 错误 - 实际和形式参数列表的长度不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!