public class SpeciesEqualsDemo2
1: //SpeciesEqualsDemo2.java
2:
3: public class SpeciesEqualsDemo2
4: {
5: public static void main(String[] args)
6: {
7: Species s1 = new Species(), s2 = new Species();
8: s1.setSpecies("Klingon Ox", 10, 15);
9: s2.setSpecies("Klingon Ox", 10, 15);
10:
11: testEqualsOperator(s1, s2);
12: testEqualsMethod(s1, s2);
13:
14: System.out.println("Now change one Klingon Ox to lowercase.");
15: s2.setSpecies("klingon ox", 10, 15); //Use lowercase
16:
17: testEqualsMethod(s1, s2);
18: }
19:
20: private static void testEqualsOperator
21: (
22: Species s1,
23: Species s2
24: )
25: {
26: if (s1 == s2)
27: System.out.println("Match with ==.");
28: else
29: System.out.println("Do Not match with ==.");
30: }
31:
32: private static void testEqualsMethod
33: (
34: Species s1,
35: Species s2
36: )
37: {
38: if (s1.equals(s2))
39: System.out.println("Match with the method equals.");
40: else
41: System.out.println("Do Not match with the method equals.");
42: }
43: }