+ 1
Do return types really matter ?
My real question is this: Does specifying a return type only matter if you're dealing with integers or doubles ?
3 Answers
+ 3
if your return type is not void you must have a return statement
you can return each object not only int or double also strings arrays lists and so on
and in java you need a return type
+ 1
If you want the function to return a value to after calculating then it matters.
If you don't need a value than use void.
+ 1
Return types are often important. Boolean particularly useful for knowing if a function succeeded or not.
We mustn't assume functions always do what we want (if they get unusual or unexpected input, they may fail). If they fail, they might pass the mess onto the next function, which could cause further problems.
Always check status codes where possible. Exceptions can be used to in some circumstances.