In the following example, I have 2 constructors: one that takes a String and one that takes a custom object. On this custom object a method \"getId()\" exists which returns
Java uses the most specific contructor it can find according to arguments.
PS: if you add constructor (InputStream) , compiler will throw error because of ambiguety - it cannot know what is more specific: String or InputStream, because they are in different class hierarchy.