That is because you can cause no end of confusion by trying to add a second statement inside the body of the if. You would probably have a second warning about having the whole statement on one line. You might also have a warning about not handling nulls correctly. Why do you think that variable might point to null ? Is null a likely value, or does it represent an error state? If you receive no error messages, all well and good, but in other circumstances maybe you are better off throwing an Exception straight away.
Randy Too wrote:. . . Based on Alibaba guideline, if statements without bracers is not encourage . . .
Yes, and no. You would not want a utility method to be overridden (actually it would usually be static, so you can't override it, only hide it). You are right that you wouldn't want different versions of the same method, so you would usually write a utility method in such a fashion that it cannot be hidden.
Hassan Syed wrote:. . . Is it a good programming practice to declare a utility method as a final method.
I presume there is a spelling error there and you meant to write a void rather than avoid.
. . . avoid type method performing some calculation and displaying the result directly. . . .
That's a pleasure
Junshi Gusza wrote:thanks . . .
Well done: please show us the finalproduect
i solved it.
No. We only delete threads which have something wrong with them.
. . . . is it possible to delete this thread?
No, I got that wrong sorry.
Norm Radder wrote:I missed where the average must be an int.
I saw: . . .