Guest User

Untitled

a guest
Jan 5th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. Bird bird1 = new Bird("Rose Starling", "Sturnus roseus", 2012);
  2. Bird bird2 = new Bird("Rose-Coloured Starling", "Sturnus roseus", 2012);
  3. Bird bird3 = new Bird("Hooded Crow", "Corvus corone cornix", 2012);
  4. Bird bird4 = new Bird("Rose-Coloured Pastor", "Sturnus roseus", 2000);
  5.  
  6. System.out.println( bird1.equals(bird2)); // same Latin name and same observation year: they are the same bird
  7. System.out.println( bird1.equals(bird3)); // different Latin name: they are not the same bird
  8. System.out.println( bird1.equals(bird4)); // different observation year: not the same bird
  9. System.out.println( bird1.hashCode()==bird2.hashCode() );
Advertisement
Add Comment
Please, Sign In to add comment