#Return array of Integers that contain indexes of an element within an array

1 messages · Page 1 of 1 (latest)

dusty veldtBOT
#

Hey, @hexed hinge!
Please remember to /close this post once your question has been answered!

stiff viper
#

Why not just iterate on the elements and add each index ? oO

#
public List<Integer> indexesOf(Object element) {
    List<Integer> indexes = new ArrayList<>();
    for(int i = 0; i < this.size(); i++) {
        if(element.equals(this.get(i))) {
            indexes.add(i);
        }
    }
    
    return indexes;
}```