code_junkie

What is the difference between equality and equivalence?

Nov 12th, 2011
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public final class CaseInsentiveitveString {
  2. ...
  3. // broken
  4. @Override public boolean equals(Object o) {
  5. if (o instance of CaseInsentiveitveString)
  6. return s.equalsIgnoreCase(
  7. ((CaseInsentiveitveString) o).s);
  8. if (o instanceof String) // One-way interoperability!
  9. return s.equalsIgnoreCase((String) o);
  10. return false;
  11. }
  12. ...
  13.  
  14. }
  15.  
  16. null == 0 # true , null is equivelant to 0 ( in php )
  17. null === 0 # false, null is not equal to 0 ( in php )
  18.  
  19. int i = 3;
  20. double d = 3.0;
  21.  
  22. int i = 3;
  23. double d = 3.0;
  24.  
  25. 0.9999999999999999... = 1
Add Comment
Please, Sign In to add comment