I only registered to reply to you, all these "answers" who are just talking nonsense, while not pointing out the error... shame on you. Try Arrays.equals(arr1, arr2) instead of arr1.equals(arr2) Next time you can use a debugger to step through your code to find the fault on your own.
PHP: public class test { public static void main(String args[]){ PetRecord test1=new PetRecord(); test1.name="test1"; test1.age=10; PetRecord test2=new PetRecord(); test2.name="test1"; test2.age=10; PetRecord test3=new PetRecord(); test3.name="test3"; test3.age=20; System.out.println(test1.compare(test2)); System.out.println(test2.compare(test3)); }}class PetRecord{ int age=0; String name=""; String getName(){ return name; }; int getAge(){ return age; }; boolean compare(PetRecord other){ boolean result=false; if(this.getName().equals(other.getName()) && this.getAge()==other.getAge()) result=true; return result; }}; it's a bit messy but you get the idea you need to use their functions that you created you cannot use equals on primitives