I have two arraylists like arraylist1 and arraylist2. I need to compare them and if they are not equal I need to take another action, than if they are equal. How I can compare all ints in these arrays and how I can compare them? I think one equal method is not enough.
Are you talking about ArrayLists or about arrays?
Usually, simply using the equals method of Lists should be good enough. This will use the equals method of all its elements. However, sometimes that's not good enough, in those cases where the elements have an equals method you can't use. Arrays are such objects.
I am assuming you have a List<int>. If this is correct, then you indeed cannot use equals itself. You will need to create a utility method that checks if two List<int> objects are equal. They are equal if:
1) they have the same size
2) each element is equal
You need to iterate over the elements of both Lists; you can then use Arrays.equals to check for the array equality.