I’ve recently discovered a nice new feature in Java 8: methods to properly handle integer overflows. Consider the following example: When you compile and run it, this is the result: Quite obviously, this can’t be mathematically right. The problem occurs because an int has a limited size of 4 byte. When this size is tooContinue reading “New in Java 8: Catching Integer Overflows”
Tag Archives: Java
Good documentation can be funny
java.lang.System.nanoTime() is used to measure time spans as precisely as possible (if you actually get nanosecond precision depends on the platform). I just found a funny warning in the documentation: Differences in successive calls that span greater than approximately 292 years (263 nanoseconds) will not accurately compute elapsed time due to numerical overflow. I didn’tContinue reading “Good documentation can be funny”
Getting network interface information in Java
How to get all available interfaces on the local host in Java, with a few additional hints for Android.