How can I make a method parameter mandatory or optional based on another parameter in Java?
For example, I have a Java method public void example(int x, int y);. Now I want that if x is provided as 0, then method should be called without providing y, i.e. example(0); should work. However, if x is not 0 then method should also require y, i.e. example(1); should not work in this case.
