Skip to content
Advertisement

Tag: comparison

Why is UUID#compareTo incompatible with RFC 4122?

Overview Javas UUID class implements Comparable. But the order it implements appears to be incompatible with the specificiation given in RFC 4122. In particular, it is inconsistent with the natural order implied by its string representation (uuid1.toString().compareTo(uuid2.toString())), which lines up with the RFC. Example You can reproduce and observe the problem by using the following code: Details My main problem

Comparing Numbers in Java

In Java, all numeric types extend from java.lang.Number. Would it be a good idea to have a method like the following: I’m concerned about cases where a double 2.00000 does not equal an int 2. Are these handled by the built-in equals? If not, is there any way to write a simple number compare function in java? (external libraries such

Java Large Files Disk IO Performance

I have two (2GB each) files on my harddisk and want to compare them with each other: Copying the original files with Windows explorer takes approx. 2-4 minutes (that is reading and writing – on the same physical and logical disk). Reading with java.io.FileInputStream twice and comparing the byte arrays on a byte per byte basis takes 20+ minutes. java.io.BufferedInputStream

Advertisement