This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
It's a common problem for methods to indicate success or failure along with a return value. If you look at String.indexOf() it returns non-negative for a successful find and -1 for not found. And if you look at BufferedReader.readLine() it returns a valid string for good reads and null for end of file. So right from the JDK we have two solutions that are not consistent.
Yikes! How many more ways will we find to indicate some special condition? Quite a few, I'm afraid.
I'd suggest two lessons from this: read the JavaDoc closely on methods you're not familiar with, and try to follow some example in your own methods and document them well so they'll make sense to others. These two examples won't always work ... some times negative answers are valid, sometimes null strings are valid. Then I guess you could look into throwing exceptions.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi