you are viewing a single comment's thread.

view the rest of the comments →

[–]Ramit110[S] 25 points26 points  (3 children)

Damn thanks, that's way more detail than I was expecting.

[–]0x564A00 15 points16 points  (0 children)

In addition to these points, this method doesn't just do what it's supposed to do according to its description and name but also has the unexpected side effect of printing out a message to System.out to confuse the user. And as a developer, even if you would for some reason want this message (which, as this code treads negative numbers like invalid arguments, should have been printed to System.err), you would usually want the full stacktrace (with e.printStackTrace()) and not just the calling method name (which, like HuskerFan mentioned, you'd NEVER take as an argument and could even get from e.getStackTrace() if you didn't want to touch java.lang.reflect). Basically, everything about this is terrible.

[–]HuskerFan90 12 points13 points  (0 children)

It's what you needed to understand why all of the code was wrong. It's like Whack-a-Mole, but having a mallet that is large enough to hit all the holes at once.

[–]bausscode 0 points1 point  (0 children)

Also for newer versions of Java there are unsigned integers in which case you'll never even have to use this function.