Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 5
    @gnat Top voted answer to that question says ...but it's difficult to comment without further information. This question is a more specific case, and I would argue therefor not a duplicate. Commented Apr 13, 2016 at 9:18
  • 5
    Not that I'm suggesting option 2 but why are you using a String[]. List<String> would give you what you need (ArrayList being the most common implementation). Arrays are sometimes useful (if for example fixed length is desired) but I reach for the list unless I have a good reason not to (or Collection if order isn't important) Commented Apr 13, 2016 at 9:46
  • Is there a particular reason you don't want to throw an exception for this? Commented Apr 13, 2016 at 10:41
  • 1
    Yes. The user might want to actually perform the calculation despite the warnings, and should be able to do so. If I threw an exception inside performCalculation I could not return anything. Commented Apr 13, 2016 at 10:44
  • 1
    @Pharap Perhaps I used a bad name. It is not out of bounds as with array indexes. Rather it is outside the region of input that has the promised precision of the calculation. Commented Apr 13, 2016 at 11:31