M
Marc Dzaebel
Hi there,
l1,l2 are of type "long" and I need to compare them. Currently I do it by
new Long(l1).compareTo(l2) // autoboxing
However, there should be a static method in Long.compareTo(long l1, long l2)
in order to avoid the generation of two unnecessary Long objects? The same
problem occurrs for other primitive types. I would always have to write a
methods like:
public static int compareTo(long l1, long l2) {
return l1<l2? -1 : l1==l2? 0 : 1;
}
Shouldn't the current design be refactored in this way or do I miss
something? May be the costs of creating the two objects (and collect them)
are not as high as I assume?
Thanks, Marc
l1,l2 are of type "long" and I need to compare them. Currently I do it by
new Long(l1).compareTo(l2) // autoboxing
However, there should be a static method in Long.compareTo(long l1, long l2)
in order to avoid the generation of two unnecessary Long objects? The same
problem occurrs for other primitive types. I would always have to write a
methods like:
public static int compareTo(long l1, long l2) {
return l1<l2? -1 : l1==l2? 0 : 1;
}
Shouldn't the current design be refactored in this way or do I miss
something? May be the costs of creating the two objects (and collect them)
are not as high as I assume?
Thanks, Marc