public class SpeciesEqualsDemo
1:
2: public class SpeciesEqualsDemo
3: {
4: public static void main(String[] args)
5: {
6: Species s1 = new Species( ), s2 = new Species( );
7: s1.setSpecies("Klingon ox", 10, 15);
8: s2.setSpecies("Klingon ox", 10, 15);
9:
10: if (s1 == s2)
11: System.out.println("Match with ==.");
12: else
13: System.out.println("Do Not match with ==.");
14:
15: if (s1.equals(s2))
16: System.out.println("Match with the method equals.");
17: else
18: System.out.println("Do Not match with the method equals.");
19:
20: System.out.println("Now change one Klingon ox to lowercase.");
21: s2.setSpecies("klingon ox", 10, 15); //Use lowercase
22:
23: if (s1.equals(s2))
24: System.out.println("Match with the method equals.");
25: else
26: System.out.println("Do Not match with the method equals.");
27: }
28: }