Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (firstElement.equals(secondElement)) {
- // Remove elements by index, not by value
- list.remove(indexes[1]); // Remove the second element first to avoid index shifting
- list.remove(indexes[0]);
- System.out.printf("Congrats! You have found matching elements - %s!\n", firstElement);
- } else {
- System.out.println("Try again!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement