Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean equals (Object o) {
- // Return false if stack sizes are different.
- if (((DoubleStack) o).doubleStack.size() != this.doubleStack.size()) {
- return false;
- }
- // Start comparing both DoubleStack one by one. Return false if mismatch is found.
- for (int i = 0; i < this.doubleStack.size(); i++) {
- if (((DoubleStack) o).doubleStack.get(i) != this.doubleStack.get(i)) {
- return false;
- }
- }
- // Return true if no mismatch is found.
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement