Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public class Scratchpad {
  2. public static void main(String[] args) {
  3. Bar o = new Bar();
  4. System.out.println(o.equals(o));
  5.  
  6. }
  7. }
  8.  
  9. class Foo {
  10. public boolean equals(Object o) {
  11. return this == o;
  12. }
  13. }
  14.  
  15. class Bar extends Foo{
  16.  
  17. }
  18.  
  19. class Bar extends Foo{
  20. public boolean equals(Bar b){
  21. return false;
  22. }
  23. }
  24.  
  25. public final boolean equals(Object o) {
  26. return o.getClass() == Foo.class && this == o;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement