Quantcast
Channel: Oracle/Java/Others
Viewing all articles
Browse latest Browse all 10

Effective Java note by Hongfeng Sun

$
0
0

Interface : java.util.Comparator : impose total ordering (more restriction)
Interface: java.lang.Comparable: compareTo method is referred to as its natural comparison method

You must override hashCode in every class that overrides equals
long -> (int)(f^(f>>> 32))
float -> Float.floatToIntBits(f)
double -> Double.doubleToLongBits(f) -> then long to int

P190: Prefer two-element enum types to boolean parameters


Viewing all articles
Browse latest Browse all 10

Trending Articles