Suppose that numpoints == 0
. Would your code ever reach the return statement?
In the other case, if your function does return, will fileOut.close();
ever be called?
Java recognizes that there is a case where the return statement might not be reached, and acts as if you didn't have one. To fix this you should have a "default" return statement at the end of the function, to handle the edge case where your loops aren't entered into.
Im not sure on the proper way to divide up my existing code to create a new method.
It's really up to you and what the code is doing, but a few guidelines:
- Method getting too long to understand? Break it up into several methods.
- Are you writing "duplicate code"? Maybe that should go in a method.
- Stuff like writing to a file is a discrete unit of operation. In other words, separate from the logic of the rest of your program. So it should be separated as its own method.
- Etc.