Is there a way to explicitly specify a constructor in Java?
constructor, java
Solution
Yes, by explicitly casting the null argument: i.e., by calling `Example((String)null);` or `Example((SomeOther) null);`
And as mentioned, doing this suggests a bad design, and I agree. You will want to try to write bullet-proof code where this sort of ambiguity isn't possible or doesn't matter.
Problem
The answer to this question explains the cause for the ambiguous constructor problem, but if I actually want to construct a third-party object which contains such constructors, and I want to pass the argument to be `null`, can I construct the object anyways by somehow telling java which constructor I mean? In particular, in this example: ``` public Example(String name) { this.name = name; } public Example(SomeOther other) { this.other = other; } ``` Suppose I want to actually construct a `new Example(null)` using the first constructor. Is there some syntax that will allow me to do this?