I have a list of items. I click on the first element and its sequence number becomes 1. Then I click on the second element - its sequence number is 2. On the third one - 3 and so on. Then I again click on the fifth and first elements and their sequence numbers are deleted. I can’t make it so that when you click on the fifth, and then on the first element, their sequence numbers become 1 and 5, respectively. And so by analogy with an arbitrary number of elements and an arbitrary choice of sequence numbers.
By task context: I have a set of cards with values and I need to select a sequence in which to display these cards on the next screen.
ArrayList? If the number is already there, then delete, if not - add. - Flippy