In Java 8 kommen neue Methoden hinzu, die eine Überlauferkennung ermöglichen. Die Methoden gibt es in Math und StrictMath: class java.lang.Math class java.lang.StrictMath static long addExact(long x, long y) static long subtractExact(long x, long y) static long multiplyExact(long x, long y) Alle Methoden werfen eine …
Was kommt nach und vor 1: Die Ausgabe ist: 1,000000119209289 0,9999999403953552 1,0000001192092896 0,9999999403953552 nextUp(d) ist eine Abkürzung für nextAfter(d, Double.POSITIVE_INFINITY) und nextDown(d) eine Abkürzung für nextAfter(d, Double.NEGATIVE_INFINITY). Ist das zweite Argument von Math.nextAfter(…) größer …
Die Ganzzahldivision in Java ist simpel gestrickt. Vereinfacht ausgedrückt: Konvertiere die Ganzzahlen in Fließkommazahlen, führe die Division durch und schneide alles hinter dem Komma ab. So ergeben zum Beispiel 3 / 2 = 1 und 9 / 2 = 4. Bei negativem Ergebnis, durch entweder negativen Dividenden oder Divisor, das …
To shorten things and not to repeat ourselves (usually the closing always looks the same) Google Commons offers the utility class com.google.common.io.Closeables. In this class you can find two static helper methods close(Closeable) and closeQuietly(Closeable). Both take an argument of type Closeable—like a …
Die Änderungen sind im Wiki dokumentiert: und referenziert . guava-16.0-rc1.jar guava-gwt-16.0-rc1.jar (for GWT users) guava-16.0-rc1-javadoc.jar (Javadoc) guava-16.0-rc1-sources.jar (Source)
Die Änderungen sind im Wiki dokumentiert: und referenziert . guava-16.0-rc1.jar guava-gwt-16.0-rc1.jar (for GWT users) guava-16.0-rc1-javadoc.jar (Javadoc) guava-16.0-rc1-sources.jar (Source)
Neu in Java 8 ist die Methode find(…) in Files um Dateien nach gewissen Kriterien zu finden. final class java.nio.file.Files static Stream<Path> find(Path start, int maxDepth, BiPredicate<Path,BasicFileAttributes> matcher, FileVisitOption… options) throws IOException Sucht einen Verzeichnisbaum rekursiv ab und wendet …
Die Utility-Klasse Files bietet vier statische Methoden (zwei mehr in Java 8), die, bei einem Startordner beginnend, die Verzeichnisse rekursiv ablaufen. final class java.nio.file.Files static Stream<Path> walk(Path start, FileVisitOption… options) throws IOException static Stream<Path> walk(Path start, int maxDepth, …
In der Klasse Files finden sich vier Methoden (eine mehr unter Java 8), um zu einem gegebenen Verzeichnis alle Dateien und Unterverzeichnisse aufzulisten: final class java.nio.file.Files static Stream<Path> list(Path dir) throws IOException (neu in Java 8) static DirectoryStream<Path> newDirectoryStream(Path dir) …