this is the error : “The method countTrue(boolean[]) in the type GUI is not applicable for the arguments (boolean, boolean, boolean, boolean, boolean)” , the error is in the last line , but i dont get why. Answer New array should be declared as below: int x = GUI.countTrue(new boolean[]{true, false, false, true, false}); OR you can use varargs and
Tag: parameters
Java create method in Interface and change the parameter type
How do I create an interface that when Overridden can have different types? Sometimes I would like the method to accept an item of type ‘HtmlPage’ and other times I would like it to take the type ‘Document’. Later these could change to even more types. Example: I am thinking something like this should be achievable. I have tried looking
The builder pattern and a large number of mandatory parameters
To date I use the following implementation of the builder pattern (as opposed to the implementation described here): This works well for most situations I’ve encountered where I need to build up a complex object with a variety of required/mandatory and optional parameters. However, I’ve been struggling lately to understand how the pattern is of any benefit when all your