I want to retrieve elements from an array, but make it so if an element position was already chosen it wouldn't be duplicated. What would be the best and/or most readable way to do this?
The method I had in mind only works for numbers, and is limited when an element has a duplicate in another position. The closest I found was this: Java - generate Random range of specific numbers without duplication of those numbers - how to? but it didn't apply since I don't need all the elements in the array. Though it made me realize a possible 'solution' would be to shuffle and then iterate through the array for the amount I require, but I was wondering how else this could be done?