Advertisement
UniQuet0p1

Untitled

Oct 3rd, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. @Override
  2. public boolean equals (Object o) {
  3. // Return false if stack sizes are different.
  4. if (((DoubleStack) o).doubleStack.size() != this.doubleStack.size()) {
  5. return false;
  6. }
  7.  
  8. // Start comparing both DoubleStack one by one. Return false if mismatch is found.
  9. for (int i = 0; i < this.doubleStack.size(); i++) {
  10. if (((DoubleStack) o).doubleStack.get(i) != this.doubleStack.get(i)) {
  11. return false;
  12. }
  13. }
  14. // Return true if no mismatch is found.
  15. return true;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement