posted 4 years ago
A method with a return value must in all cases return a value. Here, it may not, if there is no account with ID id. You may assume that there will always be such an account, but you need to convince the compiler that it will always have an Account object to return (or possibly return null otherwise).
Don't write a loop like this, without enclosing braces. My personal rule is that I *may* omit the braces if the for or if contains only a single line of code, but I rarely do. Probably rather sooner than later the time will come to add a second statement, at which point you need to remember to add braces anyway. Plus, it makes the code clearer to read for other people, or yourself, six months down the road.