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:错误: 必填:字符串,字符串
java:112: error: required: String, String
发现:字符串
原因:实际参数和形式参数列表的长度不同
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
的声明:
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屋!