Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
998 views
in Technique[技术] by (71.8m points)

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: error: required: String, String

found: String

reason: actual and formal arguments lists differ in length

Here is the method I'm trying to call:

public void setShippingDest(String inCustName, String inDestn) {
    // ...
}

Here is how I'm trying to call it:

shipOrder.setShippingDest("Broome");
Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

(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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...