Friday 15 January 2010

java - Is there a way to define a contract to implement a method with no parameter restrictions (see explanation)? -


I understand what the interface and abstract classes are, but I do not know how the following functionality can be obtained; If this is possible, then it is I have a bunch of classes, each of which has a valid () method. Each method can take different parameters. For example, we can do classes with the following methods:

  Boolean valid (); Boolean valid (block []); Boolean Valid (BlockSet []); ...   

So, basically I want to know whether I can use an interface or intangible class, or something else, with a given name, a method To define the contract and to implement the type of return, but there is no restriction on the set of parameters. thank you in advanced.

You can do it with valid (object ... args), but it's worth the question Is that what you really want interfaces and abstract clauses are useful so that you can group together a group of similar objects, and implement different operations with the same operation. I feel that you will not be able to call this method without knowing what the underlying implementation is, and therefore there is no reason to make them compromised.

No comments:

Post a Comment