Java error. Actual and formal argument lists vary in length

I am trying to call a method, but it gives this error:

java: 112: error :: String, string

found: String

reason: lists of actual and formal arguments vary in length

Here is the method I'm trying to call:

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

Here's what I'm trying to call it:

shipOrder.setShippingDest("Broome");
+4
source share
2 answers

Well, that’s pretty simple. Here's the announcement setShippingDest:

public void setShippingDest(String inCustName, String inDestn)

And here is what you call it:

shipOrder.setShippingDest("Broome");

You specified one argument, but there are two parameters? How do you expect this to work? You either need to provide another argument, or delete one parameter.

( in , ​​ JUnit, , main.)

+11

, , ,

    public void setShippingDest(String inCustName)
    {
      return  setShippingDest(inCustName, defaultvalue1);
    }

. ?

+1

Source: https://habr.com/ru/post/1534657/


All Articles