I'm curious if static methods of wrapper classes are really helpful.
Which of them are most useful and popularly used? Can you present any must-know tricks involving these methods?
Thanks in advance.
I'm curious if static methods of wrapper classes are really helpful.
Which of them are most useful and popularly used? Can you present any must-know tricks involving these methods?
Thanks in advance.
Integer.parseInt(..)
is used a lot. I don't have statistics though. I've used half of them, but of course they are all useful in certain contexts.
The compare
methods are useful to handle the primitive counterparts.
static int compare(primitive p1, primitive p2)
Compares the two specified primitive values.
Possible use:
@Override
public int compareTo(MyClass other){
return Double.compare(this.myDoubleField, other.myDoubleField);
}
Integer.toString(...)
is used for turning an integer to string without resorting to "" + i
.