java的左移和右移的區別常見的hascode和equals寫法
“>> 右移,高位補符號位” 這裏右移一位表示除2 “>>> 無符號右移,高位補0”; 與>>類似 “<< 左移” 左移一位表示乘2,二位就表示4,就是2的n次方
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Conversation that = (Conversation) o; //Conversation變成自身的類就好 return timestamp == that.timestamp; } @Override public int hashCode() { return (int) (timestamp ^ (timestamp >>> 32)); }